Main Content

Customize the Page Size and Margins of a Word Report

此示例显示了如何使用报告API报道模板来自定义页面大小以及Microsoft®WordReport的标题,页脚和排水沟。

默认情况下,报告API生成了8.5 x-11英寸的肖像页面,并具有一英寸边距。标头,页脚和水槽各有一半宽。您可能需要在报告中更改这些维度。例如,如果您正在为欧洲语言环境生成报告,则可能需要生成A4页。此示例显示了如何生成A4页面。使用相同的过程生成其他页面维度。

要更改报告API报告的页面尺寸,您必须更改由模板的模板指定的尺寸mlreportgen.report.TitlePage,,,,mlreportgen.report.tablecontents,,,,andmlreportgen.report.chapterreporters. This example shows how to modify and use the Word template for each reporter.

自定义标题页字模板

Create a copy of themlreportgen.report.TitlePage记者默认字模板。

mlreportgen.report.titlepage.createTemplate(“ titlepagetemplate.dotx”,,,,“ docx”);

在matlab®中,在Current Folderpane, right-click the template file and click在Matlab外面打开

开发人员选项卡,启用设计模式。如果是开发人员tab is not available, clickFile>选项,,,,and then click自定义功能区。在下面Main Tabs,,,,click the开发人员复选框。

插入tab, in theText小组,单击Quick Parts。选择标题页document part template.

选择文档部分模板的内容。在布局tab, in the页面设置小组,单击页面设置对话框启动器。将纸张尺寸和边距修改为A4值:

  • Top, bottom, left, right margins of 0.98 inches.

  • Header and footer heights of 0.5 inches.

  • 排水沟大小(绑定页面的空间)为0。

  • 8.27英寸乘11.69英寸的页面大小在肖像方向。

点击OKand close the dialog box.

插入选项卡,单击Quick Parts并选择Save Selection to the Quick Part Gallery

In the Create New Building Block dialog box, enter the name of the document part template you modified, that is,标题页并选择themlreportgen类别。响应提示以覆盖上一个版本。

选择文档部分模板的内容,然后保存并关闭模板。

自定义目录Word模板

Create a copy of themlreportgen.report.tablecontents记者默认字模板。

mlreportgen.report.tablecontents。createTemplate("tableOfContentsTemplate.dotx",,,,“ docx”);

在Matlab,在Current Folderpane, right-click the template file and click在Matlab外面打开

开发人员选项卡,启用设计模式。如果是开发人员tab is not available, clickFile>选项,,,,and then click自定义功能区。在下面Main Tabs,,,,click the开发人员复选框。

插入选项卡,单击Quick Parts。选择目录document part template.

选择文档部分模板的内容。在布局tab, in the页面设置小组,单击页面设置对话框启动器。将纸张尺寸和边距修改为A4值:

  • 顶部,底部,左,右边缘为0.98英寸。

  • Header and footer heights of 0.5 inches.

  • 排水沟大小(绑定页面的空间)为0。

  • 8.27英寸乘11.69英寸的页面大小在肖像方向。

点击OKand close the dialog box.

插入选项卡,单击Quick Parts并选择Save Selection to the Quick Part Gallery

In the Create New Building Block dialog box, enter the name of the document part template you modified, that is,目录并选择themlreportgen类别。响应提示以覆盖上一个版本。

Delete the content of the document part template, and save and close the template.

自定义章节字模板

Create a copy of themlreportgen.report.chapter记者默认字模板。

mlreportgen.report.chapter.createtemplate(“ ChapterTemplate.dotx”,,,,“ docx”);

在matlab®中,在Current Folderpane, right-click the template file and click在Matlab外面打开

开发人员选项卡,启用设计模式。如果是开发人员tab is not available, clickFile>选项,,,,and then click自定义功能区。在下面Main Tabs,,,,click the开发人员复选框。

插入选项卡,单击Quick Parts。选择第1节document part template.

选择文档部分模板的内容。在布局tab, in the页面设置小组,单击页面设置对话框启动器。将纸张尺寸和边距修改为A4值:

  • 顶部,底部,左,右边缘为0.98英寸。

  • Header and footer heights of 0.5 inches.

  • 排水沟大小(绑定页面的空间)为0。

  • 8.27英寸乘11.69英寸的页面大小在肖像方向。

点击OKand close the dialog box.

插入选项卡,单击Quick Parts并选择Save Selection to the Quick Part Gallery

In the Create New Building Block dialog box, enter the name of the document part template you modified, that is,第1节并选择themlreportgen类别。响应提示以覆盖上一个版本。

Delete the content of the document part template, and save and close the template.

在报告中使用自定义模板

使用自定义模板创建有关魔术正方形的单词报告,即矩阵的矩阵,其列,行和对角线每个都累加到相同的数字。

导入DOM并报告API软件包

导入DOM并报告API软件包,以避免使用完全合格的类名称。

进口mlReportgen.Report。*;进口mlreportgen.dom。*;

创建报告容器。

rpt =报告(“报告”,,,,“ docx”);

添加标题页

Create a title page and specify the title, subtitle, and author.

title = TitlePage(“标题”,,,,"Magic Squares");title.Subtitle =“列,行,对角线:所有相等的总和”;title.Author ="Albrecht Durer";

Use the custom title page template to generate the title page.

title.templatesrc = fullfile(pwd,“ titlepagetemplate.dotx”);

Add the title page to the report.

添加(rpt,title);

添加目录

toc = tableofcontents;

Use the custom table of contents template to generate the table of contents.

toc.templatesrc = fullfile(pwd,"tableOfContentsTemplate.dotx");

将目录添加到报告中。

add(rpt,toc);

添加一章

Create a chapter and specify the title.

章=章节("Introduction");

Use the custom chapter template to generate the chapter.

章节。TemplateSrc= fullfile(PWD,“ ChapterTemplate.dotx”);

创建一个部分并在其中添加段落。

sec1 =部分("What is a Magic Square?");para =段落([“一个magic square is an N-by-N matrix '...“由整数1到n^2'构建...“相等的行,列和对角线总和。”);add(sec1,para)

将部分添加到本章中。

add(chapter,sec1)

创建另一个部分并在其中添加段落。

sec2 =部分(“ Albrect Durer和魔术广场”);para =段落([...'The German artist Albrecht Durer (1471-1528) created '...'many woodcuts and prints with religious and '...'科学象征主义。他最著名的作品之一...'Melancholia I, explores the depressed state of mind '...'反对灵感和表达。'...'Renaissance astrologers believed that the Jupiter '...'magic square (shown in the upper right portion of '...'the image) could aid in the cure of melancholy. The '...可以在'中找到“雕刻”日期(1514)...“正方形中的数字较低。”);添加(Sec2,para);

将部分添加到本章中。

add(chapter,sec2);

将章节添加到报告中。

添加(RPT,章);

关闭并查看文档

关闭(RPT);RPTView(RPT);

也可以看看

||

Related Topics