Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Save to Excel From JasperViewer

I'm using JasperViewer to show the report to the user and to be able to export to pdf, word and Excel. The problem is while saving to Excel, and error prompts saying:

Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class: net/sf/jasperreports/engine/export/JRXlsExporter, 
method: createMergeRegion signature: (Lnet/sf/jasperreports/engine/export/JRExporterGridCell;IILorg/apache/poi/hssf/usermodel/HSSFCellStyle;)V) Incompatible argument to function
        at net.sf.jasperreports.view.save.JRSingleSheetXlsSaveContributor.save(JRSingleSheetXlsSaveContributor.java:104)
        at net.sf.jasperreports.swing.JRViewerToolbar.btnSaveActionPerformed(JRViewerToolbar.java:407)

Here's the code I'm using to show my report:

  public void showReport() throws SQLException {


        RNVehicle rnVehicle = new RNVehicle();
        vehicles.clear();
        vehicles= rnVehicle.getVehiculos();

        //Path to your .jasper file in your package
        String reportName = "reports/ReportVehicles.jasper";

        //Get a stream to read the file
        InputStream is = this.getClass().getClassLoader().getResourceAsStream(reportName);

        try {

            JasperPrint jp = JasperFillManager.fillReport(is, null, new JRBeanCollectionDataSource(vehicles));

            //Viewer for JasperReport
            JRViewer jv = new JRViewer(jp);

            //Insert viewer to a JFrame to make it showable
            JFrame jf = new JFrame();
            jf.getContentPane().add(jv);
            jf.validate();
            jf.setVisible(true);
            jf.setSize(new Dimension(1020, 755));
            jf.setLocation(0, 0);
            jf.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        } catch (JRException ex) {
            ex.printStackTrace();
        }
    }

I'm desperate :( , why is not running? What changes should I make? Or what libraries should I import to the project to make it run?

At the moment I have: poi-3.6.jar (the one that comes with the JR distribution), I also tried with previous versions, 3.5 and 3.2 and with all of them everything works fine, but just for html, pdf and word, not for Excel.

Any insight on this regard will be helpful.

like image 332
eddy Avatar asked Jan 18 '11 05:01

eddy


1 Answers

You need to add "poi-3.10.1.jar" in your project.

like image 153
Adel Avatar answered Oct 10 '22 08:10

Adel