cancel
Showing results for 
Search instead for 
Did you mean: 

Report off CSV data source

Former Member
0 Kudos

Hi guys,

We are using Crystal Report Server XI R2. My report uses multiple CSV files as report data source. We would like to use Java SDK to dynamically pass data source to the report. I was just wondering what is the best way for my java code to load and pass csv files to the report? All csv files for the report will be extracted to a specific folder and I know the path to the folder before running the report. All advices will be highly appreciated.

Thank you,

Jundong

Accepted Solutions (0)

Answers (1)

Answers (1)

ted_ueda
Employee
Employee
0 Kudos

The Report Application Server (RAS) SDK that allows for data "push" (injecting data from code into a Crystal Report) via the RAS server on Crystal Reports Server accepts java.sql.ResultSet via the DatabaseController.setDataSource method.

You'd need to, in your code, transform the CSV into a java.sql.ResultSet.

A sample for using ResultSet and RAS SDK is [here|https://boc.sdn.sap.com/node/3211] in RAS\set_resultset_datasource.

So the component you'd supply is the CSV -> ResultSet conversion.

One way is to use the POJO Factory described [here|http://devlibrary.businessobjects.com/BusinessObjectsXIR2SP2/en/en/JRC_SDK/jrc_pojo_api_doc/doc/jrcsdk_java_pojo_apiRef/overview-summary.html] - find pojoSample.jar file in your deployment. It provides a POJO -> ResultSet conversion factory method. So you can CSV -> POJO -> ResultSet.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Ted Ueda,

Thank you for your prompt reply. The report was designed to work with csv files. The report designer told me he can just specify the path to a folder which contains all csv files needed by the report and the report will pick them up automatically. However we don't know the path until a user trying to view a report. So, would it be possible to use Java code to change the path in the report and then just call a openDocument() to open the report with a specific folder?

Also, it seems a lot easier to use XMLDataSet. We can change data extraction format to XML. However, their still will be multiple XML files. Would it be possible to set multiple XML files (all from the same folder) as a report's data source with reportClientDocument.getDatabaseController().setDataSource(XMLDataSet)?

Thank you,

Jundong

Former Member
0 Kudos

Ted,

I read those examples you mentioned. To set a datasource in a Crystal report DatabaseController, it requires a table name. I was just wondering is the table name equals to csv file names set as datasource in the 'Set Datasource Location' dialog in Crystal Report Designer (user.csv displayed as user_csv in the dialog)? So if my report use mutiple CSV files, I should load them one by one and then set them with the DataBaseController?

Thank you,

Jundong