问题描述
当withTemplate(templateFileName)使用的模板文件数据量过大时,会报错。我使用的模板文件有17w行数据,我想在模板文件的基础上新增几列新增数据
异常代码
EasyExcel.write(fileName, DemoData.class).withTemplate(templateFileName).sheet().doWrite(data());
异常提示
Create workbook failure
com.alibaba.excel.exception.ExcelGenerateException: Create workbook failure
at com.alibaba.excel.context.WriteContextImpl.(WriteContextImpl.java:98)
at com.alibaba.excel.write.ExcelBuilderImpl.(ExcelBuilderImpl.java:36)
at com.alibaba.excel.ExcelWriter.(ExcelWriter.java:36)
at com.alibaba.excel.write.builder.ExcelWriterBuilder.build(ExcelWriterBuilder.java:114)
at com.deformity.platform.survey.business.common.service.BusinessImportService.importBusinessData$lambda-16(BusinessImportService.kt:285)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.apache.poi.util.RecordFormatException: Tried to allocate an array of length 270,579,663, but the maximum length for this record type is 100,000,000.
If the file is not corrupt or large, please open an issue on bugzilla to request
increasing the maximum allowable size for this record type.
As a temporary workaround, consider setting a higher override value with IOUtils.setByteArrayMaxOverride()
at org.apache.poi.util.IOUtils.throwRFE(IOUtils.java:599)
at org.apache.poi.util.IOUtils.checkLength(IOUtils.java:276)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:230)
at org.apache.poi.util.IOUtils.toByteArray(IOUtils.java:203)
at org.apache.poi.openxml4j.util.ZipArchiveFakeEntry.(ZipArchiveFakeEntry.java:82)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.(ZipInputStreamZipEntrySource.java:98)
at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:132)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:312)
at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:59)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:289)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.(XSSFWorkbook.java:285)
at com.alibaba.excel.util.WorkBookUtil.createWorkBook(WorkBookUtil.java:35)
at com.alibaba.excel.context.WriteContextImpl.(WriteContextImpl.java:96)
... 7 common frames omitted