使用带有新导出器配置的JRAPI参数调用时出错

w3nuxt5m  于 2021-06-30  发布在  Java
关注(0)|答案(0)|浏览(299)

我创建了一个代码,可以用jasper创建xlsx文件。我创建了一个示例来配置文件,在调用中,我创建了一个额外的参数,在这里我使用virtualizer来处理工作负载。当系统不使用virtualizer时,我可以成功下载文件,但是当我尝试使用virtualizer时会弹出错误。我不知道哪里出了问题 JRParameter 在jasper6.16中没有被否决
错误

Caused by: net.sf.jasperreports.engine.JRRuntimeException: Can't mix deprecated JRParameter API calls with new exporter configuration API calls.
    at net.sf.jasperreports.engine.JRAbstractExporter.checkApi(JRAbstractExporter.java:309)
    at net.sf.jasperreports.engine.JRAbstractExporter.setParameter(JRAbstractExporter.java:345)
    at org.springframework.ui.jasperreports.JasperReportsUtils.render(JasperReportsUtils.java:109)
    at

方法调用

ReconReportData obj= new ReconReportData();
        list2.add(0, obj);
        if( list2.size() > 50000) {
            JRAbstractLRUVirtualizer virtualizer = null; 
            virtualizer = new JRGzipVirtualizer(10); 
            parameterMap.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
        }
        // JRDataSource JRdataSource = new JRBeanCollectionDataSource(list2);
        JRDataSource rhbJRDataSource = new RhbJRDataSource<ReconReportData>(list2.iterator(), map);

        parameterMap.put("Table_Title", "Myclear Recon Transaction Detail Report  (XLS)");
        parameterMap.put("Table_Data_Source", rhbJRDataSource);

配置

public class JasperReportsXlsxView extends AbstractJasperReportsSingleFormatView {

    @Override
    protected JRXlsxExporter createExporter() {
        JRXlsxExporter xlsxExporter = new JRXlsxExporter();
        SimpleXlsxReportConfiguration configuration = new SimpleXlsxReportConfiguration();
        configuration.setOnePagePerSheet(true);
        configuration.setRemoveEmptySpaceBetweenColumns(true);

        xlsxExporter.setConfiguration(configuration);
        //Remove deprecated code for java 8
//        JRXlsxExporter xlsxExporter = new JRXlsxExporter();
//        xlsxExporter.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,  Boolean.TRUE);
//        xlsxExporter.setParameter(JExcelApiExporterParameter.IS_ONE_PAGE_PER_SHEET,  Boolean.FALSE);
        return xlsxExporter;
    }

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题