Removing Paragraphs Containing Only Template Syntax Tags
While building a report, some paragraphs containing only template syntax tags can become empty after the tags are removed or replaced with empty values. To remove such paragraphs from the report, you can apply the ReportBuildOptions.RemoveEmptyParagraphs
option as shown in the following example.
ReportingEngine engine = new ReportingEngine();
engine.Options |= ReportBuildOptions.RemoveEmptyParagraphs;
engine.BuildReport(...);
The difference in the engine’s behavior when the option is applied and not applied is illustrated by the following examples.
Example 1
Template document
Prefix
<<[""]>>
Suffix
Result document without ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
Suffix
Result document with ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
Suffix
Example 2
Template document
Prefix
<<if [false]>>
Text to be removed
<</if>>
Suffix
Result document without ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
Suffix
Result document with ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
Suffix
Example 3
Note – In this example, persons
is assumed to be a data table having a field Name
.
Template document
Prefix
<<foreach [in persons]>>
<<[Name]>>
<</foreach>>
Suffix
Result document without ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
John Doe
Jane Doe
John Smith
Suffix
Result document with ReportBuildOptions.RemoveEmptyParagraphs
applied
Prefix
John Doe
Jane Doe
John Smith
Suffix
The same functionality can be applied to selective paragraphs only. To achieve this, you can prepend names of corresponding tags with exclamation marks as shown in the following template snippet instead of applying of the ReportBuildOptions.RemoveEmptyParagraphs
option.
<<![...]>>
<<!doc [...]>>
<<!foreach [...]>>...<</foreach>>
<<!if [...]>>...<<elseif [...]>>...<<else>>...<</if>>
For a tag with its name prepended with an exclamation mark, the engine treats a corresponding paragraph or paragraphs as if ReportBuildOptions.RemoveEmptyParagraphs
was applied. For the rest of tags, the engine behaves as if ReportBuildOptions.RemoveEmptyParagraphs
was not applied.