Jump to content
Changes to the Jaspersoft community edition download ×

Exporting to Excel

2005 IR Help

Recommended Posts

By: marquis225 - marquis225

Exporting to Excel

2004-06-16 11:58

I have a jasper problem when I try to export to Excel.


I'm currently using Jasper 0.5.2 and poi 2.5.


This is the code I'm executing:


JasperFillManager jasperFillManager = new JasperFillManager();

jasperPrint = jasperFillManager.fillReport(jasperReportObject,parameters,connection);

JRXlsExporter exporter = new JRXlsExporter();

ByteArrayOutputStream xlsReport = new ByteArrayOutputStream();

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, xlsReport);


byte[] reportBytes = xlsReport.toByteArray();



response.setHeader("content-disposition", "inline;report.xls");


ServletOutputStream outputStream = response.getOutputStream();

outputStream.write(reportBytes, 0, reportBytes.length);



if(connection != null && !connection.isClosed()){try{connection.close();}catch(Exception e){}}


When I execute this code from the jsp, I get the following error:

java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.createRow(S)Lorg/apache/poi/hssf/usermodel/HSSFRow;

at dori.jasper.engine.export.JRXlsExporter.exportPage(JRXlsExporter.java:386)

at dori.jasper.engine.export.JRXlsExporter.exportReportToStream(JRXlsExporter.java:353)

at dori.jasper.engine.export.JRXlsExporter.exportReport(JRXlsExporter.java:282)


I looked into the forum and found some advice on this posting:



I edited the java file, recompiled the classes and rejared the packages, but I was getting errors like this:

C:apijasperreports_edited.jar(dori/jasper/engine/JasperReport.java):80: class JasperReport is public, should be declared in a file named JasperReport.java

(source unavailable)


So, at this point, I'm stuck. Not sure what else I can do. Any help would be appreciated.






By: gromeroq - gromeroq

RE: Exporting to Excel

2004-06-24 13:12

I have the same error:



Coud somebody help us telling us how to solve this problem?






By: Chuck Deal - cdeal

RE: Exporting to Excel

2004-06-25 06:06

It sounds like you are using the wrong version of POI for the version of Jasper that you are running.





By: gromeroq - gromeroq

RE: Exporting to Excel

2004-06-25 07:11

In my case I'm currently using Jasper 0.4.6 and poi version 1.5.1. Which other version do I have to use?






By: Chuck Deal - cdeal

RE: Exporting to Excel

2004-06-25 07:21

Well, that seems to be right.


I hate to ask the questions...but...are you SURE that those are the files that are on the classpath?





By: gromeroq - gromeroq

RE: Exporting to Excel

2004-06-25 08:34

I am sure about the files in the classpath. I think the problem seems to be a bug on JasperReports that I find in this posting:



Well, we had to dig down into the Jasper source code to find out. Look at the Jasper 0.4.6 JRXlsExporter object(dori.jasper.engine.export.JRXlsExporter) on line 386, and you'll see the following code:


row = this.sheet.createRow((short)y);


It's calling the createRow() method on a POI object named org.apache.poi.hssf.usermodel.HSSFSheet. However, it's casting the "y" var (which is an int) to a short. The new HSSFSheet.createRow() method only accepts "int" parameters, so passing it a "short" causes the error.


Is that the problem? If this is the problem I need the source code of JasperReports 0.4.6, where can I find it? Because I can only find the source code of version 0.5.3








By: Chuck Deal - cdeal

RE: Exporting to Excel

2004-06-25 10:35

If you look at the top of the SourceForge window, you'll notice a set of Links (Summary, Admin, ...) One of those links is called Files. However, when I went to Files, only Jasper versions from 0.5.0 on were listed. I looked on my drive to see if I still had the project file for 0.4.6 but no luck.


You'll have to petition some kind soul to email you the project file.

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