Jump to content
We've recently updated our Privacy Statement, available here ×

Jasperreport Excel (.xlsx) datasource


cjasper

Recommended Posts

I am trying to generate a report using excel(.xlsx) datasource .I have been able to create the datasource in iReport. I add the Report Query by clicking the "Get Field from datasource" button.


And all the fields gets generated as needed. But when i click on preview data it throws an error:


java.lang.IllegalStateException: Cannot get a text value from a numeric cell.



The .xlsx file contains some column which have both integer and string values and I think this is the reason for exception.Is there any way to get all the column values as string or any other workaround?


 


I have tried  declaring in jrxml  <field name="InspectionFullNumber" class="java.lang.Object"> <fieldDescription><![CDATA[]]></fieldDescription>  but then too no help.


I really appreciate any pointer


I suspect there should be something to set the cell type to CELL_TYPE_FORMULA before reading the cell content.


Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi!

 

This type of error is because that Excel conversion try to convert every number column as one of base number types on Java.

 

Just, when you get the fields, try to change the type of each columns from default java.lang.String to java.lang.Integer, java.landg.Float, etc.; corresponding with the original data on columns.

 

You may define date types too. Using java.util.Date

 

With those changes, your problem must be solved.

Link to comment
Share on other sites

  • 6 months later...
  • 6 months later...
  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...