Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Magic Squares Report Explorer Example

This example illustrates a report generator created with the help of the Report Explorer, the Report Generator's interactive report generation program designer. The report generator in this example generates a PDF, Microsoft Word, or HTML report on a set of four magic squares. The report generator uses templates to define the fixed content of the report and holes for inserting dynamically generated content, such as today's date.

IMPORTANT! Click the Open Script button on this page to use this example. This will download the example and its supporting files to your home directory.

Update the Report Explorer's report template cache

If you have opened the Report Explorer previously in this MATLAB session, you must update its report template cache to include the templates used in this example.

Click rptgen.db2dom.TemplateCache.getTheCache(true);

Run the Magic Report Generator

Click on any of the following to run the report generator:

Edit the Example's Word Templates

This example uses two Microsoft Word templates to generate a Word report:

  • A main template that defines the format and fixed content of the reports title, table-of-contents, and introductory chapter.

  • A chapter template that defines the layout and fixed content of the chapters containing magic squares. The magic square chapter template is stored in the Quick Parts gallery of the main template.

You can edit these templates to change the appearance of a generated report:

1. Open this example (if it is not already open).

2. Click winopen('magic_squares_docx.dotx') to open the template in Word

3. Edit the template(s) in Word.

4. Save the template(s).

5. Click report('magic','-fdom-docx','-smagic-docx') to generate a report based on the modified template(s).

Edit the Example's HTML Templates

This example uses two HTML templates to generate an HTML report:

  • A main template that defines the format and fixed content of the reports title, table-of-contents, and introductory chapter.

  • A chapter template that defines the layout and fixed content of the chapters containing magic squares. The magic square chapter template resides in the main template's document part template library.

To edit the templates:

1. Click unzipTemplate('magic_squares_html.htmtx') to unzip the template.

2. Click edit('magic_squares_html/root.html') to open the template root document in the MATLAB editor.

3. Click edit('magic_squares_html/docpart_templates.html') to open the document part templates library document in the MATLAB editor.

4. Click edit('magic_squares_html/stylesheets/root.css') to open the report style sheet in the MATLAB editor.

4. Edit the template's files in the MATLAB editor.

5. Save the templates files.

6. Click zipTemplate('magic_squares_html.htmtx') to rezip the template.

7. Click report('magic','-fdom-htmx','-smagic-html') to generate a report based on the modified template(s).

Edit the Example's PDF Templates

This example uses two PDF templates to generate a PDF report:

  • A main template that defines the format and fixed content of the reports title, table-of-contents, and introductory chapter.

  • A chapter template that defines the layout and fixed content of the chapters containing magic squares. The magic square chapter template resides in the main template's document part template library.

To edit the PDF templates:

1. Click unzipTemplate('magic_squares_pdf.pdftx') to unzip the template.

2. Click edit('magic_squares_pdf/root.html') to open the template root document in the MATLAB editor.

3. Click edit('magic_squares_pdf/docpart_templates.html') to open the report style sheet in the MATLAB editor.

4. Click edit('magic_squares_pdf/stylesheets/root.css') to open the document part templates library document in the MATLAB editor.

5. Edit the template files in the MATLAB editor.

6. Save the files.

7. Click zipTemplate('magic_squares_pdf.pdftx') to rezip the template.

8. Click report('magic','-fdom-pdf-direct','-smagic-pdf') to generate a report based on the modified template(s).

Edit the Report Generator in the Report Explorer

1. Open this example if it is not already open.

2. Click setedit('magic.rpt') to open magic.rpt in the Report Explorer.

3. Edit magic.rpt in the Report Explorer.

4. Save magic.rpt.

6. Rerun the report to see the results of your changes.

Was this topic helpful?