Jump to content
Changes to the Jaspersoft community edition download ×

How to export to XLS format???


Recommended Posts

By: Deepa Kapadia - deepa_kapadia

How to export to XLS format???

2006-04-10 23:03

Hi,

 

I have written code for export file to .xls file format, but getting following error.

 

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: net.sf.jasp

erreports.engine.JasperReport

at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport

(JRXlsAbstractExporter.java:130)

at JasperReports.ShowReport(JasperReports.java:290)

at JasperReports.actionPerformed(JasperReports.java:160)

at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)

at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)

at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)

at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source

 

 

Here is the code for export .xls file

 

JRXlsExporter exporter = new JRXlsExporter();

JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);

jasperReport = JasperCompileManager.compileReport(reportFile);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrRS);

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STREAM,jasperReport);

//exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);

exporter.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE,java.lang.Boolean.FALSE);

exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);

exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);

exporter.exportReport();

 

Plz help me out.

 

Thanx,

Deepa Kapadia

 

 

 

 

By: Deepa Kapadia - deepa_kapadia

RE: How to export to XLS format???

2006-04-11 01:43

Hi Friends,

 

I got sol'n of my problem.

Here is the code which runs perfact.

 

JRXlsExporter exporter = new JRXlsExporter();

JRResultSetDataSource jrRS = new JRResultSetDataSource(rs);

jasperReport = JasperCompileManager.compileReport(reportFile);

JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrRS);

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,destinationFile.toString());

exporter.setParameter(JRXlsExporterParameter.IS_AUTO_DETECT_CELL_TYPE,java.lang.Boolean.TRUE);

exporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);

exporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,Boolean.TRUE);

exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,Boolean.FALSE);

exporter.exportReport();

Thanx,

Deepa Kapadia

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...