문제

i am creating report using jasper report. when i create report(pdf,xls) with 12000 records it's work fine but when i create report with 40000 records problem of heap memory. the problem is only with the xls format. pdf format works fine. my code is below.

Map hm = new HashMap();
JasperPrint print = null;
JRSwapFileVirtualizer virtualizer = null;
    JRSwapFile swapFile = new JRSwapFile("D://", 2048, 1024);
virtualizer = new JRSwapFileVirtualizer(2,swapFile,true);
JRVirtualizationHelper.setThreadVirtualizer(virtualizer);
hm.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(
                    list);
JRExporter exporter = null;
            if (type.toUpperCase().equalsIgnoreCase(FileTypes.PDF.name())) {
                exporter = new JRPdfExporter();

            } else if (type.toUpperCase().equalsIgnoreCase(FileTypes.XLS.name())) {
                exporter = new JRXlsExporter();
            }

            if(exporter != null)
            {
                exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
                        outFileName);
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
                exporter.exportReport();
            }
도움이 되었습니까?

해결책

I found the soluation of this question . i have added the IS_IGNORE_PAGINATION to the xls file so it works fine.

Map hm = new HashMap();
JasperPrint print = null;
JRSwapFileVirtualizer virtualizer = null;
JRSwapFile swapFile = new JRSwapFile("D://", 2048, 1024);
virtualizer = new JRSwapFileVirtualizer(2,swapFile,true);
JRVirtualizationHelper.setThreadVirtualizer(virtualizer);
hm.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
if (type.toUpperCase().equalsIgnoreCase(FileTypes.XLS.name()))
{
    hm.put(JRParameter.IS_IGNORE_PAGINATION, new Boolean(false));
}
JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(
                    list);
JRExporter exporter = null;
            if (type.toUpperCase().equalsIgnoreCase(FileTypes.PDF.name())) {
                exporter = new JRPdfExporter();

            } else if (type.toUpperCase().equalsIgnoreCase(FileTypes.XLS.name())) {
                exporter = new JRXlsExporter();
            }

            if(exporter != null)
            {
                exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,
                        outFileName);
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
                exporter.exportReport();
            }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top