gpt4 book ai didi

java.lang.NoSuchMethodError : org. apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper()Lorg/apache/poi/hssf/usermodel/HSSFCreationHelper;

转载 作者:行者123 更新时间:2023-11-30 10:26:58 25 4
gpt4 key购买 nike

在我使用 jasperreports-3.7.4 jar 以 Excel 格式下载 Jasper Reports 之前。现在我正在尝试升级到 jasperreports-6.3.1 jar。但它在调用时显示错误,如“java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper()Lorg/apache/poi/hssf/usermodel/HSSFCreationHelper;exporterXLS.exportReport() 方法。我也在使用 poi-3.6 jar。请提供解决此问题的解决方案。请在下面找到我的代码。

    handleDataBase db=null;
try {

OutputStream OutputStream = res.getOutputStream();
db = new handleDataBase();
Utility.comment("attra","before loading the Report "+new java.util.Date() + " - file name is "+reportFileName);
Connection connObj = db.getConnection();
//String jrPrint =JasperFillManager.fillReportToFile(jrxmlFile,params,connObj);
JasperPrint jasperPrint = JasperFillManager.fillReport(jrxmlFile, params, connObj);
Utility.comment("attra","After loading the Report "+new java.util.Date()+ " - file name is "+reportFileName);

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();


JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JRXlsExporterParameter.JASPER_PRINT,jasperPrint);
exporterXLS.setParameter(JRXlsExporterParameter.OUTPUT_STREAM,byteArrayOutputStream);
exporterXLS.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
//****************************Newly added by Shubham***************************************
exporterXLS.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER,Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET,Boolean.FALSE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_DETECT_CELL_TYPE,Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_IMAGE_BORDER_FIX_ENABLED,Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_FONT_SIZE_FIX_ENABLED,Boolean.TRUE);
exporterXLS.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS,Boolean.FALSE);
//***
exporterXLS.setParameter(JRXlsExporterParameter.IGNORE_PAGE_MARGINS,Boolean.TRUE);
//*****************************************************************************************
exporterXLS.exportReport();//**Here I am getting above error**

//To enable report to get downloaded in IE on an https connection
res.setHeader("Cache-Control", "public");
res.setHeader("Pragma", "public");

res.setHeader("Content-Disposition","filename=\"" + reportFileName + "\";");
res.setContentType("application/vnd.ms-excel");
OutputStream.write(byteArrayOutputStream.toByteArray());
OutputStream.flush();
OutputStream.close();

} catch (Exception e) {
Utility.comment("attra","Exception inside generateReport "+e.getMessage());

} finally{
db.close();
}

最佳答案

您可能需要将 Apache POI 升级到 3.8 或更高版本。 getCreationHelper() 更改自:

public CreationHelper getCreationHelper() {
return new HSSFCreationHelper(this);
}

到:

public HSSFCreationHelper getCreationHelper() {
return new HSSFCreationHelper(this);
}

从 3.8 开始。

关于java.lang.NoSuchMethodError : org. apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper()Lorg/apache/poi/hssf/usermodel/HSSFCreationHelper;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45481255/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com