Hope this helps someone.
I would like to create a main report, which gets its data from a relational database (using a JDBC connection), but want my subreport to get its related data from an Excel spreadsheet.
Creating the main report is straightforward. For the subreport, you have to use the Excel Data Source to get the data.
1. To pass the Excel Data Source to your subreport, select the subreport and under Properties -> Connection Type, select "Use a datasource expression".
2. In Data Source Expression, enter new net.sf.jasperreports.engine.data.JRXlsDataSource(new File("C:\\\\Path\\\\To\\\\Excel_File.xls")). This will create a new instance of the datasource.
3. In your Subreport, use COLUMN_0, COLUMN_1 etc as the fields.
4. Everything from Excel is of type java.lang.String. So if you are passing parameters to your subreport, make sure you typecast them to String.
And thanks, what you have put will be very helpful for subReports.
I am running into another difficulty dealing with "Excel as a Datasource", (using the standalone iReports 4.01).
I create the Excel database connection, but when I try to see the fields in the inspector, they don't show up.
From another dialog, I can see the data from Excel, and displays it in a JTable.
But still not able to access the fields to put on the report page.
I saw a kind error that said that "this is not a JDBC source" , something like that.
But I did not use that option, I used the option for Excel.
Also I have another problem with the way it grabs data from Excel.
It assumes that your data basically starts in row1(+ or - a header).
My excel sheets, the tabular data starts from row 20, the previous rows contain account details/description of what the
1) how do you tell iReports to start looking at the data from a particular row.
2) I have multiple sheets with data in a workBook, how do i traverse and look at the different sheets.
Your help will be greatly appreciated.
I have a main report through which i want to access subreport.Im using excel sheet as datasource for subreport .when i compile subreport individually it provides me answer but when i try to see answer through mainreport its showing me blank pages.Can anyone help me out in this?