Adding CSV Format to Reports
Posted on 12/11/2023
CSV Format
Reports in BIRT Studio can be updated to run in CSV format. CSV stands for “Comma separated values” and is a text file format that uses commas to separate values. Configuring a report to run in CSV format is useful if the data inside the report needs to be exported to another system or application and they require the data to be in CSV format. Getting a BIRT Studio report to run in CSV Format is a simple process that just requires a few steps in and out of the report.
A report run in CSV format will only return the raw data from the report. This means that formatted data and modified column headers will return as they do from the database. For example, you format a date in your report from January 1, 2024 to 1/1/2024. When the report is run in CSV format, the date will return however it is returned from the database, in this case, January 1, 2024. This is just an example and may not be how dates are returned.
Configuring the Report Design
Setting the Table Name
The first thing that needs to be done to setup the report design for CSV format, is to set a table name on the table that is going to be exported. Select the entire table by selecting a single column then clicking the table bar above the column headers. The entire table will be selected when a blue border is around the entire table. Click the Properties icon to open the Table Properties. A drawer will open on the right side. Fill in the top text box labeled Table Name. Click OK when done.
If a report design contains multiple tables, only one can be used in the CSV format.
Setting the CSV_EXPORT_TABLE_NAME Parameter
After the table is set, the next step is to set the CSV_EXPORT_TABLE_NAME parameter. To do this, click on Data > Manage Parameters and click the Edit icon next to the CSV_EXPORT_TABLE_NAME parameter. A window will appear in the middle of the screen. In the Default Value text box, enter the table name that was set in the previous step. Click OK when done.
Setting the CSV_EXPORT_COLUMN_NAMES_ORDER Parameter
To set the CSV_EXPORT_COLUMN_NAMES_ORDER parameter, you should take note of the column binding names that are set in the Report Data Object. These are whatever value is in the Label field for each column. The steps for this will assume all default label names. Click on Data > Manage Parameters and click the Edit icon next to the CSV_EXPORT_COLUMN_NAMES_ORDER parameter. A window will appear in the middle of the screen. In the Default Value text box, enter the names of the column bindings in the order you’d like them to appear in the CSV report, separated by a semicolon. An example output may look like:
Employee Full Name;Employee ID;Actual Total Hours (Include Corrections);Actual Total Apply Date;Paycode Name
This is just an example but your parameter should look like this as well when complete.
Computed columns can be used in the parameter as well, but make sure that you use the computed column's binding name and not the label name.
When you are done editing the Default Value, click OK. After setting the two parameters described in the two previous steps, the report design is done and if the report is unpublished, it can be published following the steps from the Getting Started section.
Do not edit the "Required" checkbox for either of the CSV parameters. This will cause the report to fail when run. It is disabled by default and should not be enabled.
Configuring the Report Options
Setting the Available Formats
On the Report Options page (after clicking “Edit” on the Published Report), select CSV from the Output formats. This will check off the format and make it available when run. If this is all you wanted to do and you do not want to change the default format, you can click Save and the report will be ready to run in CSV format.
(Optional) Setting the Default Format
To set the default format as CSV, select it from the Default Output Type dropdown. Click Save to save your changes.
Troubleshooting CSV Reports
The steps involved to troubleshoot CSV reports and the errors that can occur are different than the steps involved to troubleshoot general issues that can occur in BIRT Studio so this gets its own section. The only issue that can occur with a CSV report is that the report will fail. This can happen for a few reasons.
- The value for the CSV_EXPORT_TABLE_NAME or CSV_EXPORT_COLUMN_NAMES_ORDER parameter is incorrect
- There is a misspelling or incorrect column binding name entered into the CSV_EXPORT_COLUMN_NAMES_ORDER parameter
In either case, go back into the report design and make sure that the values for the parameters are correct. For the table name, make sure it matches what is set in the Properties of the table. For the column names, make sure that nothing is misspelled and that the column binding names are correct. Remember that the column binding names are whatever is set in the Label field for each column in the Report Data Object.
If the report completes successfully for CSV format, and there is another issue inside with the data, then the issue is not with the CSV Parameters or the CSV format. The issue could be in the report design or an issue with the data itself. If you are unsure of where the issue is coming from, open a case with Support.