How to insert HTML dynamically into template using LINQ Reporting Engine?
To insert HTML that is generated at runtime, use the HTML insertion tags that the LINQ Reporting Engine provides.
The tag evaluates an expression that returns a string (or other supported type) containing the HTML markup and replaces the tag with the rendered content.
Syntax
<<[html_expression] -html>>
<<html [html_expression]>>
Optional switch – preserve the source document’s styles:
<<html [html_expression] -sourceStyles>>
Typical usage
<<html [booking.NoticeHtml]>>
If booking.NoticeHtml contains
<p><strong>Gate changed:</strong> B12</p>
the paragraph is inserted into the report at the tag’s location.
Steps
- In your DOCX template, place one of the HTML tags where the HTML should appear.
- Ensure the expression (
booking.NoticeHtmlin the example) resolves to a string with valid HTML. - Build the report as usual; the engine will replace the tag with the rendered HTML.
References
- Dynamic Insertion Tags – details on the
<<html …>>tag and switches. - Reporting – Create a Template – overview of template placeholders.