Using CSV File as a Data Source via OOJDBC
Logi 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.
Below is a list of the sections covered in this topic:
Importing the CSV File Directly using the Model Wizard
To import the CSV file directly using the Model Wizard, take the following steps:
- Run ModelWizard.bat in
<install_root>\bin
to open the Object Source Wizard. - Select File > Import Text Files to bring up the Open Text Files dialog.
- Browse to the file employee.csv and then check the First Line Is Column Name checkbox.
- Select Open and the table Employee will now have been added to the Object Source Wizard.
- In the Object Source Wizard, select 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 Logi JReport catalog, take the following steps:
- Start Logi JReport Designer.
- Select File > New Catalog.
- 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 inC:\odf
. - In the Catalog Manager, right-click the node of a data source and select New JDBC Connection from the shortcut menu. Select JDBC in the Select Connection Type dialog.
- 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.
- Select OK to set up the connection.
- In the prompted guidance dialog, select Add Tables.
- In the Add Tables dialog, select the table Employee and select Add.
- Select 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 Logi 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.