General Text Output

Text output is a very powerful feature of NCReport. It can generate various kinds of text output, such as HTML, XML, or plain text. Text output requires an additional text template, so besides the report definition, you also have to specify the template file before running the report.

Text output is generated very quickly, because the data is substituted directly into the text template without any graphical rendering.

Text template manager tags

The following tags are available when you create a text template. Each pair of begin and end tags delimits the template of a report section. The tags are written as standard HTML comments, and each tag must be at the beginning of a separate line. The text between the tags may contain data source, parameter, variable, and field references ($D{}, $P{}, $V{}, $F{}), which are replaced with their current values every time the section is processed.

Text template tags

Tag keyword

Description

<!-- BEGIN {DH} -→

Document header begins. The document is the text output itself; the document header is written once, at the beginning of the output (for example, the HTML head part).

<!-- END -→

Section ends

<!-- BEGIN {DF} -→

Document footer begins. It is written once, at the end of the output (for example, the closing part of an HTML document).

<!-- END -→

Section ends

<!-- BEGIN {PH} -→

Page header section begins.

<!-- END -→

Section ends

<!-- BEGIN {PF} -→

Page footer section begins.

<!-- END -→

Section ends

<!-- BEGIN {RH} -→

Report header section begins.

<!-- END -→

Section ends

<!-- BEGIN {RF} -→

Report footer section begins.

<!-- END -→

Section ends

<!-- BEGIN {D.DetailID} -→

Detail section begins. The section is identified by the detail ID.

<!-- END -→

Section ends

<!-- BEGIN {GH.DetailID.GroupID} -→

Group header section begins. The section is identified by both the detail ID and the group ID.

<!-- END -→

Section ends

<!-- BEGIN {GF.DetailID.GroupID} -→

Group footer section begins. The section is identified by both the detail ID and the group ID.

<!-- END -→

Section ends

Examples

The following example shows a typical usage of a text template:

<!-- BEGIN {DH} -->
SIMPLE TEXT REPORT OUTPUT
<!-- END -->
<!-- BEGIN {PH} -->
Customer ID       Name             Address
-----------------------------------------------
<!-- END -->
<!-- BEGIN {D.Detail1} -->
$D{custid}        $D{custname}     $D{address}
<!-- END -->

Running a report to text output

To run a report to text output from code, use the runReportToText() function, which takes the output file name and the template file name:

NCReport *report = new NCReport();
report->setReportFile( "customers.ncr" );
report->runReportToText( "customers.txt", "customers_template.txt" );

For more information about the text output class, see Text output.