BackPrevious Page Next PageNext

Using CSV File as a Data Source via OOJDBC

Importing the CSV file directly using the Model Wizard

Importing the ODF file into a catalog

JReport Designer supports CSV as a data source which can be accessed via OOJDBC. You can use this method to import Excel files by using Excel to save the report as .csv.

Here is an example demonstrating how to import a CSV file to an ODF file generated by the Model Wizard. In this example, employee.csv in <install_root>\help\samples\OOJDBC will be used. Store it to <install_root>\Demo\Reports\TutorialReports first. Then follow the steps below to import the file to a catalog.

Importing the CSV file directly using the Model Wizard

To import the CSV file directly using the Model Wizard, take the following steps:

  1. Run ModelWizard.bat in <install_root>\bin to open the Object Source Wizard.
  2. Select File > Import Text Files to bring up the Open Text Files dialog.
  3. Browse to the file employee.csv and then check the First Line Is Column Name checkbox.

    Open Text Files dialog

  4. Click Open and the table Employee will now have been added to the Object Source Wizard.

    Object Source Wizard

  5. In the Object Source Wizard, click File > Save. You will then be prompted to save the ODF file. You should save it to <install_root>\lib or to the directory where the catalog will be located. Here, we save it as employee_csv.odf.

    Note: The same ODF file cannot exist in both <install_root>\lib and the directory where the catalog will be located.

Importing the ODF file into a catalog

To import the generated employee_csv.odf file into a JReport catalog, take the following steps:

  1. Start JReport Designer.
  2. Click File > New Catalog.
  3. In the New Catalog dialog, specify the catalog name, the data source name and the path. The catalog should be located in the directory where you saved the ODF file. For example, if you saved the ODF file in C:\odf, the new catalog should be created also in C:\odf.
  4. In the Catalog Manager, right-click the node of a data source and select New JDBC Connection from the shortcut menu. Click JDBC in the Select Connection Type dialog.
  5. In the Get JDBC Connection Information dialog, enter com.jinfonet.jdbc.obj.ObjectDriver in the Driver text field, type jdbc:jinfonet:object:@Filename in the URL text field. @Filename should be the ODF file name. In the example, it is jdbc:jinfonet:object:@employee_csv.

    Get JDBC Connection Information dialog

  6. Click OK to set up the connection.
  7. In the prompted guidance dialog, click Add Tables.
  8. In the Add Tables dialog, select the table Employee and click Add.

    Add Tables dialog

  9. Click Done to close the Add Tables dialog.

Now, the table Employee will be added into the catalog. You can use it to develop reports as required.

Note: When you publish the catalog and its reports to JReport Server, whether the ODF file is located in <install_root>\lib or in the directory where the catalog is located, it will be published to the path where the catalog is located on the server side.

BackPrevious Page Next PageNext