views:

240

answers:

1

Hi Experts,

i need to export to excel and csv format in jasper reports. for excel i tried by creating custom class (using api)but it is not exporting, the thing is save and cancel popup window is coming with file type unkown..

any idea why it is happening?

A: 

Use as a JRXlsExporter to export to XSL and a JRCsvExporter for CSV.

There should be no need to create a custom class in most cases.

Edit

The class is stored inside the jar poi-3.5-FINAL-20090928.jar, which should be locate in your "iReportInstallationFolder"\modules\ext\

For me it's C:\Program Files\Jaspersoft\iReport-3.7.4\ireport\modules\ext\

The name could be different but should be poi-3.5-FINAL-*.jar.

Make it is included in your classpath and you should be fine.

You can download the jar from Apache Poi home page.

Here is a link to the jar I have from their site http://archive.apache.org/dist/poi/release/bin/poi-bin-3.5-FINAL-20090928.tar.gz

Gordon
@Gordon.. i got the exception like "Uncaught exception thrown in one of the service methods of the servlet: InvestorConfirmServlet. Exception thrown : java.lang.NoClassDefFoundError: org.apache.poi.hssf.usermodel.HSSFCellStyle".. i put .jar file also in the classpath. but even it throws error...
Manu
@Manu I updated my answer. Hopefully should help.
Gordon
can you give me the link to download the jar files...
Manu
and also can you tell me how to set parameter for exporting the excel sheet..
Manu
Do you mean tell the report to export to xsl? Please edit you answer.
Gordon
by using JRXlsExporter it is not exporting, the thing is save and cancel popup window is coming with file type unkown..
Manu
Have you tried exporting your file with a different exporter? You report may be empty.
Gordon
data is there..can you give some example? i code is like this..reportExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint); reportExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, reportStream); where reportStream is object of "ByteArrayOutputStream()". contenttype is "response.setContentType("application/xls");"
Manu