HtmlReport
No edit summary
No edit summary
Line 2: Line 2:


XHtmlReportAsString
XHtmlReportAsString
==== HTML documents ====
You can also use html templates. If the template used ends with .htm or .html the logic expects a well formed html document and will expand tags just as in OpenDocument formats - but the we will check for row-builders %%+ROWBUILDERTAG& in <nowiki><tr></nowiki> context (html tables)
====XML documents====
XML is just the more generic case of html. They are treated by the same logic. You can from 20190919 use any xml-tag as row builder. Example<pre>
<SomeXml attrib='%SomeVMColumnAsAttributeresult%'>    %SomeOtherVMColumnAsXMLTextresult%  <Items>    <Item>%%+TheVMNestingColumn%      <ContentInItem someattrib='%VMColInNesting%'>          %StuffFromViewModelNesting%      </ContentInItem>    </Item>  </Items> </SomeXml> </pre>
====Viewmodel additions====
====Viewmodel additions====
The templates is can be accessed in several different ways;
The templates is can be accessed in several different ways;
Line 22: Line 28:
|Blob with an uploaded document template, value is expected to be Base64Encoded
|Blob with an uploaded document template, value is expected to be Base64Encoded
|}
|}
====OpenDocument Text - ODT====
Tips when editing "open document text" odt files in MS Word
Any font changes (even if not visible) will interfere MDrivens detection of what to replace in your document. If you encounter this, copy the text (including %) and paste as "plain text" replacing the previous text.
Line break will will interfere MDrivens detection of what to replace in your document. Use Words text section settings and select "no line breaks" to avoid these problems.
====OpenDocument sheets - ODS====
OpenDocument excels - ODS document has issues to use data as numbers if we do not explicitly say that it is a number.
The problem is that our data-tags like %Something% that corresponds to ViewModelColumns are interpreted as text by excel - so our template will always believe that all cells fill with data is text.
To help you avoid this we have introduced this naming conversion :
{| class="wikitable"
!ViewModelColumn name ending with
!Interpreted by report logic as
!Data must
!
|-
|float
|excel value-type float
|pass decimal.TryParse
|
|-
|percentage
|excel value-type percentage and excel value = sent in value /100
|end with a % and data before % must pass decimal.TryParse
|
|}Use these naming suffixes in ViewModels that constitute reports for excel in order to get excel to understand that the value in an excel cell should be interpreted as a float or percentage - default will be interpreted as string.
===='''Note!'''====
When creating OpenDocument documents, consider using the tag '''%meta%''' in your document to get the exact tag list for your document.
When creating OpenDocument documents, consider using the tag '''%meta%''' in your document to get the exact tag list for your document.


Line 58: Line 35:


2020-04-06: Please also note that we have seen some issues with corrupt downloads when the ods template is created in OpenOffice 4.1.X. If the template is created in Excel is the document downloaded properly.
2020-04-06: Please also note that we have seen some issues with corrupt downloads when the ods template is created in OpenOffice 4.1.X. If the template is created in Excel is the document downloaded properly.
====HTML documents====
You can also use html templates. If the template used ends with .htm or .html the logic expects a well formed html document and will expand tags just as in OpenDocument formats - but the we will check for row-builders %%+ROWBUILDERTAG& in <nowiki><tr></nowiki> context (html tables)
See [[Microsoft office and OpenDocument as a Report generator]] for an example.
====XML documents====
XML is just the more generic case of html. They are treated by the same logic. You can from 20190919 use any xml-tag as row builder. Example<pre>
<SomeXml attrib='%SomeVMColumnAsAttributeresult%'>    %SomeOtherVMColumnAsXMLTextresult%  <Items>    <Item>%%+TheVMNestingColumn%      <ContentInItem someattrib='%VMColInNesting%'>          %StuffFromViewModelNesting%      </ContentInItem>    </Item>  </Items> </SomeXml> </pre>

Revision as of 22:06, 18 June 2020

The HTML generating functions share most of it's code with the OpenDocument functionality.

XHtmlReportAsString

HTML documents

You can also use html templates. If the template used ends with .htm or .html the logic expects a well formed html document and will expand tags just as in OpenDocument formats - but the we will check for row-builders %%+ROWBUILDERTAG& in <tr> context (html tables)

XML documents

XML is just the more generic case of html. They are treated by the same logic. You can from 20190919 use any xml-tag as row builder. Example

 <SomeXml attrib='%SomeVMColumnAsAttributeresult%'>     %SomeOtherVMColumnAsXMLTextresult%   <Items>     <Item>%%+TheVMNestingColumn%       <ContentInItem someattrib='%VMColInNesting%'>          %StuffFromViewModelNesting%       </ContentInItem>     </Item>   </Items> </SomeXml> 

Viewmodel additions

The templates is can be accessed in several different ways;

  • From an String attribute in a modeled class
  • From an URL
  • From the local filesystem
  • From the database in BLOB attribute in a modeled class (base64 encoded)

The viewmodel providing the report data also has attributes with specific names providing information to the report functionality.

Attribute name Attribute should evaluate to Value type and content
TemplateUrl The URL or local filename String with for example http://www.mdriven.net/templates/report.odt or for prototyping c:\\temp\\mytemplate.odt
TemplateBlob A class attribute containing the template Blob with an uploaded document template, value is expected to be Base64Encoded

When creating OpenDocument documents, consider using the tag %meta% in your document to get the exact tag list for your document.

Copy the tag name including the percent signs from the generated meta tag information (preferable without style). The %meta% must be first string in element in order to be recognized - it is also case sensitive.

If you type it or edit a part of the tag name, your editor can insert invisible control information that's interfere with the merging.

2020-04-06: Please also note that we have seen some issues with corrupt downloads when the ods template is created in OpenOffice 4.1.X. If the template is created in Excel is the document downloaded properly.

This page was edited 40 days ago on 03/26/2024. What links here