One of the most requested features for ReportingCloud is a way to merge formatted content into merge fields. We have added this feature to the API and rolled it out last weekend.
The MergeSettings object used in the Merge method received the new property mergeHtml that specifies whether field data can contain formatted HTML content or not.
If this property is set to true, field data can contain simple HTML formatting such as <strong>, <em> and <u>. The complete field data string must be enclosed in an <html> tag element:
<html><strong>Strong text</strong> and <em>emphasized text</em></html> |
In most cases, this feature has been requested to merge formatted comments into templates. Consider the following sample template:
The following code uses the ReportingCloud .NET Wrapper which is available as a NuGet package:
Report report = new Report(); | |
report.comments = "<html><strong>Longer strong text</strong>"; | |
report.comments += "with normal text and <em>emphasized text</em></html>"; | |
ReportingCloud rc = new ReportingCloud("username", "password"); | |
MergeBody body = new MergeBody(); | |
body.MergeData = report; | |
body.MergeSettings = new MergeSettings() { MergeHtml = true }; | |
List<byte[]> documents = rc.MergeDocument( | |
body, | |
"comments.tx", | |
ReturnFormat.TX, | |
true, | |
false); |
The screenshot below shows the formatted HTML that has been merged into the merge field:
The initial font name, font-size, color and font background color will be maintained on updating the text during the merge process.
Test this on your own and create a ReportingCloud trial account today.
Happy coding!