SamplePage
(Replacing message template with parser tag)
No edit summary
Line 48: Line 48:
Trigger print out using the created class action and first print out will return all tags available for printing out data. Use these tags to format structure your report document.
Trigger print out using the created class action and first print out will return all tags available for printing out data. Use these tags to format structure your report document.


If you dont want to use the %meta% tag to print out the available tags first. You may use the column names directly with the same expression. %<ColumnName>%.
If you dont want to use the %meta% tag to print out the available tags first. You may use the column names directly with the same expression %<ColumnName>%.






To print out nested columns in a table format.


Create table add the expression
To print out nested ViewModel data in a table format.
 
Create table and add the expression
{| class="wikitable"
{| class="wikitable"
|+
|+
Line 61: Line 62:
|%<Column Name>%  
|%<Column Name>%  
|}
|}
[[File:OpenDocumentTemplateViewModel.png|alt=ViewModel Template for Printing out Model-Driven data to OpenDocument reports|none|thumb|752x752px|ViewModel Template]]
 
[[File:OpenDocumentTemplateForWord.png|alt=Office Text Document for Printing out model-driven data using OpenDocument format|none|thumb|739x739px|Text Template File]]
==== ViewModel Template for Printing Out Text Open Document ====
[[File:OpenDocumentTemplateViewModel.png|alt=ViewModel Template for Printing out Model-Driven data to OpenDocument reports|none|thumb|752x752px]]
 
==== Text Document Template ====
Located at <YourModelFileName>_AssetsTK/Content/mytemplate.odt and accessible at <nowiki>http://localhost:8182/content/mytemplate.odt</nowiki>
[[File:OpenDocumentTemplateForWord.png|alt=Office Text Document for Printing out model-driven data using OpenDocument format|none|thumb|739x739px]]




Line 68: Line 74:


  When using Microsoft Office Word, [https://support.microsoft.com/en-us/office/differences-between-the-opendocument-text-odt-format-and-the-word-docx-format-d9d51a92-56d1-4794-8b68-5efb57aebfdc Check here] for format styling that is supported in OpenDocument format.
  When using Microsoft Office Word, [https://support.microsoft.com/en-us/office/differences-between-the-opendocument-text-odt-format-and-the-word-docx-format-d9d51a92-56d1-4794-8b68-5efb57aebfdc Check here] for format styling that is supported in OpenDocument format.
Create a Word template:


  %Class2[Name=Hello1]Name%
=== Spread Sheet Document ===
What this means is that we are navigating to ViewModel column Class2 – but this is a list – and filter the result on the ViewModel column Name of ViewModelClass Class2. Taking the one with value “Hello1” – for that Class2 we use the Name column… Example:
'''1.''' Start by creating an OpenDocument spread sheet document using any office application that supports OpenDocument format.
 
'''2.'''  Add <code>%meta%</code> tag within  the document as this will be used to print out all the available tags within our ViewModel for printing out Model data or use the column names directly with the same expression %<ColumnName>% 
 
where,
 
<ColumnName> represents the column name in ViewModel  
 
'''3.'''  Use <code>.ods</code> extension for spread sheet documents and your url path will now be <code>'<nowiki>http://localhost:8182/content/mytemplate.ods'</nowiki></code>. 


==== ViewModel Template for Printing Out Spread Sheet Open Document ====
[[File:viewmodel-template-for-spreadsheet-open-document.png|alt=Spread Sheet Document ViewModel Template|none|thumb|919x919px]]
Adding <code><span class="col-red">_float</span></code> at the end of a column name ensures that output in excel is processed as a number.


==== Spread Sheet Template ====
Located at <YourModelFileName>_AssetsTK/Content/mytemplate.ods and accessible at <nowiki>http://localhost:8182/content/mytemplate.ods</nowiki>
[[File:spreadsheet-document-template.png|alt=Spread Sheet Document Template|none|thumb|927x927px]]


[[File:Reporting 17.png|frameless|420x420px]]
==== Sample Spread Sheet Output ====
[[File:spreadsheet-sample-output.png|alt=SpreadSheet Sample Output|none|thumb|921x921px]]
 





Revision as of 03:05, 30 June 2024

Generate Reports Using OpenDocument and Microsoft Office

OpenDocument format is an open file format standard for office applications compatible with Microsoft office and open source applications like LibreOffice and OpenOffice.

Common filename extensions used of OpenDocument documents are:

  • .odt for text documents
  • .ods for spreadsheet documents

Mdriven applications allow generating reports from model-driven data using OpenDocument format.

Text Document

1. Start by creating an OpenDocument text document using any office application that supports OpenDocument format.

2. Add %meta% tag within the document as this will be used to print out all the available tags within our ViewModel for printing out Model data.

Note: Make sure to write tags without spaces between the word(meta) and the percentage(%) signs.

Saving Strategies

a) Temporary Location
(i) Create a folder named temp in your C:/ directory and save your file in the directory as mytemplate.odt.
(ii) Your url path will now be 'c:\\temp\\mytemplate.odt'.
b) Permanent Location (AssetsTK Strategy)
(i) This strategy allows your template document to be uploaded with your model onto the server running your Turnkey application during deployment.
(ii) Go to the location where your .modlr file is saved.
(iii) Create a folder with the name in the format of <YouModelFileName>_AssetsTK where <YouModelFileName> is the name of your .modlr file name.
(iv) Within the folder create another folder named content where your save your template document.
(v) Your url path will now be 'http://localhost:8182/content/mytemplate.odt'
(vi) Check here on how to have a dynamic url for when your deploy your application onto the Mdriven Server.

3. Create a ViewModel with the Name OpenDocumentReportTemplate. This ViewModel will be used a template for the Model-Driven data to generate reports

4. Within the ViewModel context menu, click Add column > Add columns needed for Report or create columns TemplateUrl and ReportFileName within the viewmodel.

5. Select the view model to view the settings on the right. Uncheck Use placing hints section at the top.

6. In the TemplateUrl column expression, enter the url path created earlier using any of the saving strategies above.

In the ReportFileName column expression, enter a file name for the new OpenDocument that will be generated in the format '<FileName>.odt' where <FileName> is the name of your file.

create a class action within the ViewModel whose data your want to print out using the expression below;

self.opendocumentreportshow(<classname>.ViewModels.OpenDocumentReportTemplate)

where <classname> is the root class of the viewmodel.

within OpenDocumentReportTemplate add columns whose data you want to print out.

Trigger print out using the created class action and first print out will return all tags available for printing out data. Use these tags to format structure your report document.

If you dont want to use the %meta% tag to print out the available tags first. You may use the column names directly with the same expression %<ColumnName>%.



To print out nested ViewModel data in a table format.

Create table and add the expression

%%+<Nested ViewModel Column Name>%%<First Column Name>% %<Column Name>% %<Column Name>%

ViewModel Template for Printing Out Text Open Document

ViewModel Template for Printing out Model-Driven data to OpenDocument reports

Text Document Template

Located at <YourModelFileName>_AssetsTK/Content/mytemplate.odt and accessible at http://localhost:8182/content/mytemplate.odt

Office Text Document for Printing out model-driven data using OpenDocument format


The table format is for both text documents and spreadsheet documents.
When using Microsoft Office Word, Check here for format styling that is supported in OpenDocument format.

Spread Sheet Document

1. Start by creating an OpenDocument spread sheet document using any office application that supports OpenDocument format.

2. Add %meta% tag within the document as this will be used to print out all the available tags within our ViewModel for printing out Model data or use the column names directly with the same expression %<ColumnName>%

where,

<ColumnName> represents the column name in ViewModel

3. Use .ods extension for spread sheet documents and your url path will now be 'http://localhost:8182/content/mytemplate.ods'.

ViewModel Template for Printing Out Spread Sheet Open Document

Spread Sheet Document ViewModel Template
Adding _float at the end of a column name ensures that output in excel is processed as a number. 

Spread Sheet Template

Located at <YourModelFileName>_AssetsTK/Content/mytemplate.ods and accessible at http://localhost:8182/content/mytemplate.ods

Spread Sheet Document Template

Sample Spread Sheet Output

SpreadSheet Sample Output



OpenDocument Configurations and Settings












The MDriven Book - See:Prototyping

This page was edited 2 days ago on 07/01/2024. What links here