isCOBOL IDE : Reports : How to print Reports
How to print Reports
Retrieving data for the Report
The way you retrieve data for the Report depends if you rely on Tagged Areas or not in your code.
For programs that don’t use Tagged Areas (default), follow these steps:
write COBOL statements that allow you to retrieve the first data record in the BeforeDoPrint procedure of your Report.
Code example:
       report-1-bef-do-print.
           move low-value to prd-key
           start product key not < prd-key
              invalid
                 move 0 to report-1-doprintrtn-loop
              not invalid
                 move 1 to report-1-doprintrtn-loop
                 read product next no lock
                    at end
                       move 0 to report-1-doprintrtn-loop
                 end-read
           end-start
           .
<ReportName>-doprintrtn-loop is a variable declared automatically by the IDE. When you set this variable to 0 the print loop is interrupted, when you set it to 1 the print loop continues.
write COBOL statements that allow you to retrieve the next record for the Report in the AfterDoPrint procedure of your Report.
Code example:
       report-1-aft-do-print.
           move 1 to report-1-doprintrtn-loop
           read product next no lock
                at end
                   move 0 to report-1-doprintrtn-loop
           end-read
           .
For programs that use Tagged Areas, follow these steps:
write COBOL statements that allow you to retrieve data for the Report in the paragraph "is-<reportname>-master-print-loop", that is always generated when a Report is present. Write your statements outside of the tagged area in that paragraph
 
Code example:
           move low-value to prd-key
           start product key not < prd-key
             invalid
               continue
              not invalid
               perform until 1 = 2
                 read product next
                   at end
                     exit perform
                 end-read
                 perform IS-REPORT-1-DO-PRINT-RTN
              end-perform
           end-start.
Note that for each record read in the above loop, the paragraph IS-<ReportName>-DO-PRINT-RTN is performed. Such paragraph is responsible for printing the data.
Printing the Report
The following paragraphs are always generated for programs with reports. You can perform them in your program logic. Choose the proper one according to the desired printer output:
Paragraph Name
Action
is-report-name-preview
Opens the Report in a Print Preview
 
The preview dialog is very similar to the one shown by the SpoolPrinter class (com.iscobol.rts.print.SpoolPrinter) and the Print Preview, but the preview dialog generated by the IDE also allows you to export the report to xls and xlsx files.
See Exporting to Excel file below for details.
is-report-name-print
Prints the Report on the active printer
is-report-name-print-pdf
Prints the Report to a PDF file. The name and location of the PDF file are calculated according to the output file name property. If the report name specified by that property didn’t have any extension, a ".pdf" extension is appended to it. If the name specified by that property had an extension, such extension is replaced with ".pdf".
 
Use the "@[display]:" prefix followed by a client side path (e.g. "@[display]:C:\Temp\myReport.pdf" ) to generate the report on the client machine when the program runs in a thin client environment. The "@[display]:" prefix is automatically ignored when running out of a thin client environment.
is-report-name-print-xls
Prints the Report to an Excel workbook in XLS format. The name and location of the XLS file are calculated according to the output file name property. If the report name specified by that property didn’t have any extension, a ".xls" extension is appended to it. If the name specified by that property had an extension, such extension is replaced with ".xls".
 
Use the "@[display]:" prefix followed by a client side path (e.g. "@[display]:C:\Temp\myReport.xls" ) to generate the report on the client machine when the program runs in a thin client environment. The "@[display]:" prefix is automatically ignored when running out of a thin client environment.
is-report-name-print-xlsx
Prints the Report to an Excel workbook in XLSX format. The name and location of the XLSX file are calculated according to the output file name property. If the report name specified by that property didn’t have any extension, a ".xlsx" extension is appended to it. If the name specified by that property had an extension, such extension is replaced with ".xlsx".
 
Use the "@[display]:" prefix followed by a client side path (e.g. "@[display]:C:\Temp\myReport.xlsx" ) to generate the report on the client machine when the program runs in a thin client environment. The "@[display]:" prefix is automatically ignored when running out of a thin client environment.
is-report-name-print-tofile
Prints the Report to an HTML file. The name and location of the HTML file are controlled by the output file name property.
is-report-name-setup-print
Shows the Choose Printer dialog, then print the Report on the chosen printer
Exporting to Excel file
The Export menu in the print preview dialog allows you to export the current report to either a XLS or XLSX file.
The export process can be configured through specific properties. See Export to Excel feature for details.
There are few limitations if compared with the HTML report:
Header and footer information like the page number are skipped and don’t appear in the Excel file.
If the report includes more lines than the maximum number of lines allowed by the XLS format, then the report is automatically split into multiple spreadsheets.
If the report includes more columns than the maximum number of columns allowed by the XLS format, then the export fails, but no error is shown.