java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFCellStyle.setShrinkToFit(Z)V


Up until jasperreports 6.0.0 everything was just fine and then it started to throw exception: "java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFCellStyle.setShrinkToFit(Z)V" when we tried to export jasper as xls file. We have a simple code that exports jsprerreport as xls file in a stream. What went wrong?

    public byte[] renderXls(JasperPrint print, boolean demo) throws Exception {
        byte[] bytes = null;

        try {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            JRXlsExporter exporter = new JRXlsExporter();
            exporter.setExporterInput(new SimpleExporterInput(print));
            exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(

            if (demo) // Demo verzija
                SimpleXlsxReportConfiguration sxrc = new SimpleXlsxReportConfiguration();

            bytes = stream.toByteArray();
        } catch (Exception e) {
            throw new Exception(e.getMessage());

        return bytes;



Best regards.


bojan.subotic's picture
Joined: Nov 21 2014 - 2:06am
Last seen: 8 years 2 weeks ago

3 Answers:

I got the same error even after recompiled all reports using  v.6.0.3.  Any solution?  Thanks, Truong

ngocdien's picture
Joined: Mar 4 2015 - 11:08am
Last seen: 7 months 3 weeks ago

I got the same error .  Any solution?   Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,Thanks,

1021866588's picture
Joined: Mar 17 2016 - 6:13am
Last seen: 6 years 10 months ago

As a workaround you can export XLSX instead of XLS.

franky4's picture
Joined: Jan 5 2016 - 2:15am
Last seen: 2 weeks 6 days ago