[Resolved] Report (JDBC) + Subreport (Excel)

0

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.

max_max_mir's picture
Joined: Jul 21 2010 - 9:03am
Last seen: 4 days 15 hours ago

3 Answers:

0

Hi,

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

data is.

Question:

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.

Sincerely,

Paluee

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

paluee's picture
1
Joined: Mar 3 2011 - 7:20am
Last seen: 3 years 7 months ago
0

Hi,

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?

rashmi_prabhu's picture
Joined: May 29 2011 - 11:18pm
Last seen: 3 years 4 months ago
0

I am facing the error when i followed the above approach . It is not able to read the column name and flashing the error as

Column name not found

honeybakliwal's picture
Joined: Sep 8 2010 - 2:37am
Last seen: 2 weeks 12 hours ago
Feedback