MATLAB 帮助中心
本页采用了机器翻译。点击此处可查看英文原文。
类: mlreportgen.report.Section 命名空间: mlreportgen.report
(不建议) 在该部分添加内容
add(section,content)
注意
不推荐使用 add。请改用 append。请参阅版本历史记录。
add
append
add(section,content) 将指定的内容添加到指定的节。
section
content
全部展开
mlreportgen.report.Section
报告的节,指定为 mlreportgen.report.Section 对象。
要添加到节的内容,指定为以下值之一:
报告 API 报告器
DOM 对象
内置 MATLAB® 对象(大多数内置 MATLAB 对象可以添加到 Section 报告器)
Section
可以单独添加到节的对象元胞数组
向段落添加内容并将段落添加到一章中的一节。要将内容添加到段落,必须使用 append,因为段落是 DOM API 对象。要将段落添加到节中,将节添加到章中,并将章添加到报告中,本示例使用 add。从 R2020b 开始,您可以使用 append 代替 add。请参阅版本历史记录。
import mlreportgen.dom.* import mlreportgen.report.* rpt = Report("My Report"); ch = Chapter("My Chapter"); s = Section("My Section"); p = Paragraph("My paragraph content "); append(p,"and some more content."); add(s,p); add(ch,s); add(rpt,ch); close(rpt); rptview(rpt);
全部折叠
从 R2020b 开始,使用 append 方法(而不是 add 方法)向这些报告 API 类的对象添加内容:
mlreportgen.report.Report
mlreportgen.report.Chapter
slreportgen.report.Report
要向 DOM API 对象添加内容(例如 mlreportgen.dom.Paragraph 对象),请继续使用 DOM 对象的 append 方法。使用 append 向报告 API 对象添加内容的优势在于,您使用与向 DOM API 对象添加内容相同的方法名称。
mlreportgen.dom.Paragraph
没有计划删除 Report、Chapter 或 Section 类的 add 方法。使用 add 方法的报告 API 程序将继续运行。
Report
Chapter
要更新现有代码,请将方法名称 add 替换为 append,如表中示例所示。
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); add(sect,para); add(ch,sect); add(rpt,ch); close(rpt); rptview(rpt);
import mlreportgen.report.* import mlreportgen.dom.* rpt = Report("My Report","pdf"); ch = Chapter("My Chapter"); sect = Section("My Section"); para = Paragraph("My Content "); append(para,"more Content"); append(sect,para); append(ch,sect); append(rpt,ch); close(rpt); rptview(rpt);
mlreportgen.report.Section | mlreportgen.report.Reporter | mlreportgen.report.Report | append
mlreportgen.report.Reporter
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处