[Crystal Reports] [How To] Export report to binary

Forge Component
Published on 2015-11-11 by Carlos Henriques
3 votes
Published on 2015-11-11 by Carlos Henriques
How to export a report to binary?

1) Create a new report in the CrystalReports App:

Code: unique code / key for your report. The reports will be exported by this code.
Connection: a database connection to set in runtime (manage database connection in the Connections area).

2) Add a report version

- Upload the report file (.rpt / .rptr);
- Optionally write the version notes / changes;

In the end you must have one active version:

3) Reference the ExportToBinary public action

- In your eSpaces, add reference to the ExportToBinary action and ExportFormat static entity from the CrystalReports eSpace.

4) Add the logic to export a Crystal Report to binary and download it

- In your print / export flow, add the action ExportToBinary and the Download flow element;

5) ExportToBinary action properties

Code: the same code you've set in step (1), when you've created the report in the CrystalReports app;
ExportFormatId: one of the ExportFormat static entity records. Default value is PDF;
Database: if you want to override the default database of the database connection at runtime. It's usefull if you want to export the same report for multiple databases in the same server;
SelecionFormula: set the report selection formula at runtime. You must use the same Crystal Reports formula syntax;
Parameters: expects a list of the data type Parameter (CrystalReportsExtension structure). Set this if the reports has parameters;
Formulas: expects a list of the data type Formula (CrystalReportsExtension structure). If you want or need to override report formulas at runtime.

6) Download flow element properties

use the output of the ExportToBinary action;
FileName: you can use the second output of the ExportToBinary action to get the exported file extension. You will get something like ".pdf" or ".xls", ...

How to pass report parameters?

1) Add local variables

Create local variables of type:
  • Parameter: record (CrystalReportsExtension structure)
  • Parameters: list of Parameter (CrystalReportsExtension structure)
  • Formula: record (CrystalReportsExtension structure)
  • Formulas: list of Formulas (CrystalReportsExtension structure)

2) Change the flow

  • For each parameter you will need a pair of Assign flow element and ListApend system action;

3) Set the Parameter record in the Assign

  • Parameter.Name: (string) the name of the parameter in the report (exact match);
  • Parameter.Value: (object) the value to pass to the parameter;

4) Pass the Parameter List to the ExportToBinary action

  • You can append as many parameters as you need. In this example I'm just passing one. You just need to append them all to the same Parameter List variable;
  • For the formulas, the process is the same. The Formula record has the same structure as the Parameter Record, a name and a value;
  • In the same ExportToBinary action you can combine SelectionFormula override with Parameters and Formulas; 

There seems to be an issue when using multiple parameters in the list....

The report is generated using only the last parameter appended.

Could this be an issue with the extension, or the crystal report itself?

FYI The report parameter has enabled multiple values, and the selection formula is set to

{Table.Field} in {?Parameter}



Any update for OS 11?