• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
      • Templated Reports
      • Report.save Function
      • Report.view Function
      • Report.write Function
    • HTML and JavaScript Integration
    • Action Invoker
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Templated Reports

(Prior to CSPro 7.7, a different version of templated reports existed. That version can no longer be used as it was removed in CSPro 8.0.)
Overview
CSPro can create HTML reports using case data as well as results from queries into paradata and other data sets. By specifying tags in the templated reports, CSPro logic can be run and CSPro dictionary variables can be accessed to render a dynamic report.
Functionality
Each templated report is a CSPro logic object and the following functions can be called via dot notation:
FunctionDescription
saveSaves the report to a file.
viewDisplays the report in an embedded web browser.
writeWrites text to the report.
In addition to these object functions, templated reports can be used as arguments to the filename and view functions.
Frequency tables can be written directly to a report using the Freq.save function.
Assignments
When a templated report is used as an argument to a user-defined function (as a Report object), it is passed by reference.
Add, Remove, and Rename
A templated report can be added to the project by selecting Add Files under the Files menu. If creating a new HTML file, an additional dialog will be displayed with template options. The templates have an HTML scaffolding which includes popular CSS and JavaScript libraries. A templated report can be removed from the project by selecting Drop Files under the Files menu.
The name of the report will be automatically created based on the filename, but can be modified using the Report Properties dialog.
CSPro Logic
CSPro logic can be embedded in the templated report by starting the logic with <? and ending the logic with ?>. The tag can be used to embed inline logic or multiple lines of logic.
Output
There are three ways of writing numeric and string expressions to templated reports:
  1. ~~...~~ writes the results of the numeric or string expression specified between the tildes.
  2. ~~~...~~~ is similar to the above version except that the text will not be automatically escaped for HTML.
  3. $.write writes directly to the report.
Preview
A templated report can be previewed in both data entry and batch by pressing Ctrl + F5. This will not run the CSPro logic, so the preview will not necessarily look complete. Use it to preview the HTML and CSS.
Example 1
<p>Report generated at ~~timestring()~~</p>
Example 2
<?
   
numeric partial_count = 0;
   
numeric complete_count = 0;

   
forcase HOUSEHOLD_DICT do
       
if ispartial(HOUSEHOLD_DICT) then
           
inc(partial_count);
       
else
           
inc(complete_count);
       
endif;
   
endfor;
?>
   
<p><b>~~getsymbol(HOUSEHOLD_DICT)~~</b> has ~~partial_count~~ partial case(s) and ~~complete_count~~ complete case(s).</p>
See also: HTML in CSPro, JavaScript Interface