Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Apache POI - Jasper to Excel

617176May 6 2009
Hi all, maybe this isn't the best place to write an Apache related question. However, the apache forum doesn't have one single thread on its own tech. So I am asking anyone, do you know how to outstream an excel file from a jasper file. What I am having trouble is compatibility issues with several .jar versions.

What we are using is:
poi-2.0-final-20040126.jar
jasperreports-2.0.5.jar
itext-1.3.1.jar

I read somewhere how to do this, they even posted another .jar to use, which 'somehow' miraculously 'heals' the missing classes (jxl-2.4.2.jar). However, none of this works. I even tried with poi-3.2-FINAL-20081019.jar, but there is always something missing. Right now I am missing:
 java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFSheet.createDrawingPatriarch()Lorg/apache/poi/hssf/usermodel/HSSFPatriarch; 
It's either this or that.

It would be of great significance to me if there is someone who might know which of the .jar versions combination is the right one.

This is my code below from the servlet:
    public String generateReport(HttpServletRequest request, HttpServletResponse response) throws SQLException, ClassNotFoundException, IOException, JRException
    {
        JRXlsExporter exporterXLS = new JRXlsExporter();
        
        File inputJasper = null;

        response.setContentType("application/vnd.ms-excel");
        response.setHeader("Content-Disposition","attachment;filename=\"" + "test" + "\".xls");

        OutputStream output = response.getOutputStream();

        String filePath = "C:\\";
        String fileName = "rep_u_izradi";

        inputJasper = new File(filePath + fileName + ".jasper");

        // popunjavanje ako se vuce iz jasper fajla
        JasperPrint print = JasperFillManager.fillReport(inputJasper.getPath(), new HashMap(), new JREmptyDataSource());

        //Kreiranje Excel fajla
        exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT, print);
        exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output);
        /*
        exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
        exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
        /**/

        exporterXLS.exportReport();

        output.flush();
        output.close();

        return null;
    }
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2009
Added on May 6 2009
0 comments
1,902 views