Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in exporting jasper report to Exel  RSS feed

 
pallavi chaudhari
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first of all sorry i did not found the appropriate forum to post the problem related to jasper report.

I have the code to export jasper report to the PDF and is working in the project but now client requierment is for excel sheet. I tried but not succeeded for exporting jasper report to excel sheet.

i am getting exception :============= am giving tomcat log


net.sf.jasperreports.engine.JRException: The cell cannot be added
at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1091)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportPage(JRXlsAbstractExporter.java:557)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:434)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:197)
at org.maniks.slite.common.business.ReportHelper.toExcel(ReportHelper.java:64)
at org.maniks.slite.documentation.windows.ReportWindow.callBlDraftReport(ReportWindow.java:271)
at org.maniks.slite.documentation.windows.ReportWindow.onLoad(ReportWindow.java:81)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at bsh.Reflect.invokeMethod(Unknown Source)
at bsh.Reflect.invokeObjectMethod(Unknown Source)
at bsh.Name.invokeMethod(Unknown Source)
at bsh.BSHMethodInvocation.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.BSHPrimaryExpression.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at bsh.Interpreter.eval(Unknown Source)
at org.zkoss.zk.scripting.bsh.BSHInterpreter.exec(BSHInterpreter.java:100)
at org.zkoss.zk.scripting.util.GenericInterpreter.interpret(GenericInterpreter.java:292)
at org.zkoss.zk.ui.impl.PageImpl.interpret(PageImpl.java:766)
at org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:178)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:143)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.process0(EventProcessingThreadImpl.java:488)
at org.zkoss.zk.ui.impl.EventProcessingThreadImpl.run(EventProcessingThreadImpl.java:422)
Caused by: java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.addMergedRegion(Lorg/apache/poi/hssf/util/Region;)I
at net.sf.jasperreports.engine.export.JRXlsExporter.createMergeRegion(JRXlsExporter.java:558)
at net.sf.jasperreports.engine.export.JRXlsExporter.exportImage(JRXlsExporter.java:1072)
... 25 more

and please have look at my code....and make me correct


 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Apache POI library is either not recent enough or too recent. The Jasper library tries to call a method that either has been added in a later version or has been dropped (the former is more likely). Try switching to a different version, preferably the latest.

Edit: I checked HSSFSheet, and the method (int addMergedRegion(Region)) should still exist but is has been deprecated for almost two years already. You may even need to upgrade your Jasper library.
 
varghese ps
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried different version of POI. I was using poi-3.7-20101029.jar
when I used poi-3.5-FINAL-20090928.jar the exception gone but having new exception as
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.setRightToLeft(Z)V
at net.sf.jasperreports.engine.export.JRXlsExporter.createSheet(JRXlsExporter.java:290)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReportToStream(JRXlsAbstractExporter.java:584)
at net.sf.jasperreports.engine.export.JRXlsAbstractExporter.exportReport(JRXlsAbstractExporter.java:320)
at exportToExel.MainClass.main(MainClass.java:50)
 
Tony Docherty
Bartender
Posts: 3264
81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

The error message is saying there is no method in HSSFSheet called setRightToLeft(Z) so it looks like the versions you are using of Jasper and POI are not compatible.
I suggest you check the documentation for your version of Jasper and see what version of POI it will work with.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!