Hi, I am fairly new to JasperServer, and I am trying to deploy a new report to JasperReports Server 5.0.0 using an Excel data source. I successfully connected my Excel file as a data source to create the report using iReport, but I do not understand how to add that Excel file to JasperServer so that I can connect it to the report on the server. When I am logged into JasperServer using the default admin accout, "jasperadmin," I right-click on "Data Sources" on the left side of the screen and then I select "Add Resource > JasperReport." Then I see this page:
I select my local JRXML file and type the name "testPieChart," and then I select the "Data Source" button on the left, where you set up the data source connection. Then, I select the option to "Click here to create a new data source" which then brings me to this page:
Under the drop-down menu for "type" there are options for
- Bean Data Source
- Hadoop-Hive Data Source
- Internal Diagnostic Data Source
- JDBC Data Source
- JNDI Data Source
- Mongo DB Data Source
- Virtual Data Source
So, how to I create an Excel data source? Do I use one of the above types? I really need to use Excel files as data sources for my application so any help would be extremely appreciated.
Edit - I'm sorry about the formatting of the screen shots
Hi, here are the proper steps to resolve this issue:
1. Get your xls file (data should be stored in columns, smth like JR table report) and rename it to xls_data.xml
2. Upload it to the server with the name xls_data into /reports folder
3. Create xls_data_provider.xml, like:
6. In JRS goto Add new report and use previously created jrxml, don't select any datasource in wizard
It's done, now you should be able to run report.
To use flat files as a datasource (like XLS files) you need to use DataAdapters in Jasperserver instead of regular datasources. Data Adapters are part of JasperSoft Studio but you can create them manually in the server (it's just and XML file). You have some examples using CSV as a data adapter in the standard Jasper Server Samples (under /Reports/Interactive).
For using XLS your data adapter has to be something like this:
<!--?xml version="1.0" encoding="UTF-8" ?--> <xlsdataadapter class="net.sf.jasperreports.data.xls.XlsDataAdapterImpl"></xlsdataadapter> <name>ExcelData</name> <filename>/path/of/your/excelfile.xls</filename> <usefirstrowasheader>true</usefirstrowasheader> <datepattern>M/d/yy h:mm a</datepattern> <numberpattern>#,##0.###</numberpattern> <queryexecutermode>false</queryexecutermode> <columnnames>Column1Name</columnnames> <columnnames>Column2Name</columnnames> <columnnames>Column3Name</columnnames> <columnnames>Column4Name</columnnames> <columnIndexes xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.Integer">0</columnIndexes> <columnIndexes xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.Integer">1</columnIndexes> <columnIndexes xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.Integer">2</columnIndexes> <columnIndexes xmlns:xsi="http: //www.w3.org/2001/XMLSchema-instance" xsi:type="java:java.lang.Integer">3</columnIndexes>
Thank you Marianol. I have added the XML file, but I do not quite understand the last part of your comment. Do you mean that I add those attributes to the 'xlsdataadapter' tag of the XML file (i.e. property name="net.sf.jasperreports.data.adapter" value="repo:/reports/Test/XLS_Data_Adapter.xml") ?
Also does that mean that under the "Data Source" section of my report I will select "Do not link a data source"? Should I put any information about this data adapter under the "Controls & Resources" section?