主要内容

报告生成嵌入式Web视图

报告生成嵌入式Web视图,创建类的实例,它定义了发电机(见报告创建一个嵌入式Web视图报告生成器)。然后,使用填满关闭报告生成器的方法。

例如,假设您希望创建一个报告使用SystemDesignVariables类的例子(见为嵌入式Web视图类定义文件)。这些命令生成和显示该报告的一个实例:

模型=“f14”;rptName = sprintf (“% sVariables”模型);load_system(模型);rpt = SystemDesignVariables (rptName模型);填充(rpt);关闭(rpt);close_system(模型);rptview (rptName);

填充(rpt)命令使用填满方法,该报告生成器从基类继承。该方法嵌入的网络视图f14模型在报告中。它还称fillContent方法报告的发电机,它填补了文档窗格与报告所使用的变量f14模型。

这里是结果的一部分嵌入Web视图报告:

对导航信息的不同部分报告,明白了嵌入式Web导航视图报告

为嵌入式Web视图类定义文件

这个类生成一个报告使用的工作区和数据字典变量指定的仿真软件万博1manbetx®模型。

classdef SystemDesignVariables < slreportgen.webview。EmbeddedWebViewDocument % SystemDesignVariables报告所使用的变量%仿真软件模型定义了一个类报告生成器生成HT万博1manbetxML报告%工作区和数据字典变量使用的仿真软件%模型。生成的报告包括这些信息为每个变量%:% %值(如果是一个标量值,数值)%数据类型%源(e。g,路径包含变量)%的字典的源类型(例如,数据字典或基工作区)%用户(街区道路使用的变量)方法函数rpt = SystemDesignVariables (reportPath modelName) % EmbeddedWebViewDocument构造函数调用,而%保存报告路径和模型名称%使用报告的填写方法。rpt@slreportgen.webview.EmbeddedWebViewDocument (reportPath……modelName);%关闭复制链接警告以避免使用多个设计变量的警告%街区。rpt。ValidateLinksAndAnchors = false;rpt.ExportOptions。IncludeMaskedSubsystems = true; rpt.ExportOptions.IncludeSimulinkLibraryLinks = true; rpt.ExportOptions.IncludeReferencedModels = true; end function fillContent(rpt) % Fill the Content hole in the report template with design % variable information. You can use DOM or Report API methods % to create, format, add, and append content to this report. %% Set up report % Allow use of unqualified names for DOM and Report objects, % such as Paragraph instead of mlreportgen.dom.Paragraph and % TitlePage instead of mlreportgen.report.TitlePage. import mlreportgen.dom.* import mlreportgen.report.* % Obtain model name, which was saved by the report % constructor. getExportedModels returns model names as a % cell array, in case a report uses multiple models. model = getExportModels(rpt); % Extract the model from the cell array. (This report uses % only one model.) model= model{1}; % Add a title page to the report add(rpt, TitlePage("Title",[model " Report"],"Author","")); % Find variables used by the reported model finder = slreportgen.finder.ModelVariableFinder(model); % Create a Variables Chapter ch = Chapter("Variables"); while hasNext(finder) result = next(finder); % Create a section for the variable s = Section(result.Name); % Add variable information to the section using % default reporter settings reporter = getReporter(result); add(s,reporter); % Add this section to the chapter add(ch,s); end % Add the chapter to the report add(rpt,ch); end end end

生成设计变量之间的双向链接的用户路径和块在Web视图中使用的设计变量,取代这些行代码:

%变量信息添加到部分使用%默认记者设置记者= getReporter(结果);添加(年代,记者);

这行代码:

%与链接嵌入模型创建一个用户列表usedByPara =段(使用:“);usedByPara。大胆= true;添加(年代,usedByPara);用户= result.Users;nUsers =元素个数(用户);u = 1: nUsers userLink = createElementTwoWayLink (rpt,用户{你},段落(用户{你}));添加(年代,userLink);结束