3
异常代码
public class PackageInfoRowMergeStrategy implements CellWriteHandler {
/**
* 需要合并的行
*/
private HashSet<Integer> mergeRowIndex;
public PackageInfoRowMergeStrategy(HashSet<Integer> mergeRowIndex) {
this.mergeRowIndex = mergeRowIndex;
}
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
if(CollectionUtils.isEmpty(mergeRowIndex)){
return;
}
for(Integer num : mergeRowIndex){
CellRangeAddress cellRangeAddress = new CellRangeAddress(num, num, 0, 3);
writeSheetHolder.getSheet().addMergedRegionUnsafe(cellRangeAddress);
}
}
}
private void buildExcelFile(String fileName, List<T> t, Class<T> cls) {
log.info("开始组装excel 文件内容 {}",taskEntity.getUniqueId());
ExcelWriterBuilder write = null;
if (dynamicHead) {
write = EasyExcel.write(fileName).head(getHeadList());
} else {
write = EasyExcel.write(fileName, cls);
}
final List<WriteHandler> handler = getHandler();
if (CollectionUtils.isNotEmpty(getHandler())) {
for (WriteHandler h : handler) {
write.registerWriteHandler(h);
}
}
log.info("excel 文件内容 生成完成,开始生成excel文件 {}",taskEntity.getUniqueId());
write.needHead(needHead).sheet("sheet1").doWrite(t);
log.info("excel 生成完成,等待上传 {}",taskEntity.getUniqueId());
/
/
![WechatIMG166](https://github.com/alibaba/easyexcel/assets/78678528/b49a90e5-de44-4251-bf9f-b9973a246849)
日志截图
![image](https://github.com/alibaba/easyexcel/assets/78678528/765b433a-3fdd-437d-92fc-1ce20ac8d4fe)
服务器文件
![WechatIMG166](https://github.com/alibaba/easyexcel/assets/78678528/0e677286-9206-47b4-9ec3-12b1a97b5c3b)
在执行 生成excel 后,不在输出日志
执行到这行,超过了3分钟
这个下面是jstack 抓取的信息
"ZmsKafkaConcurrentlyConsumeThread_ils-domain-task-topic-export-consumer_1" #206 prio=5 os_prio=0 tid=0x00007fa62000f800 nid=0xd1 runnable [0x00007fa6889db000]
java.lang.Thread.State: RUNNABLE
at org.apache.xmlbeans.impl.store.Locale.count(Locale.java:2062)
at org.apache.xmlbeans.impl.store.Xobj.count_elements(Xobj.java:2068)
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTMergeCellsImpl.sizeOfMergeCellArray(Unknown Source)
- locked <0x00000000c4d58588> (a org.apache.xmlbeans.impl.store.Locale)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegion(XSSFSheet.java:420)
at org.apache.poi.xssf.usermodel.XSSFSheet.addMergedRegionUnsafe(XSSFSheet.java:386)
at org.apache.poi.xssf.streaming.SXSSFSheet.addMergedRegionUnsafe(SXSSFSheet.java:399)
at com.zto.ils.task.strategy.PackageInfoRowMergeStrategy.afterCellDispose(PackageInfoRowMergeStrategy.java:44)
at com.alibaba.excel.write.handler.CellWriteHandler.afterCellDispose(CellWriteHandler.java:101)
at com.alibaba.excel.write.handler.chain.CellHandlerExecutionChain.afterCellDispose(CellHandlerExecutionChain.java:54)
at com.alibaba.excel.write.handler.chain.CellHandlerExecutionChain.afterCellDispose(CellHandlerExecutionChain.java:56)
at com.alibaba.excel.write.handler.chain.CellHandlerExecutionChain.afterCellDispose(CellHandlerExecutionChain.java:56)
at com.alibaba.excel.write.handler.chain.CellHandlerExecutionChain.afterCellDispose(CellHandlerExecutionChain.java:56)
at com.alibaba.excel.util.WriteHandlerUtils.afterCellDispose(WriteHandlerUtils.java:148)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addJavaObjectToExcel(ExcelWriteAddExecutor.java:216)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.addOneRowOfDataToExcel(ExcelWriteAddExecutor.java:82)
at com.alibaba.excel.write.executor.ExcelWriteAddExecutor.add(ExcelWriteAddExecutor.java:58)
at com.alibaba.excel.write.ExcelBuilderImpl.addContent(ExcelBuilderImpl.java:59)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:70)
at com.alibaba.excel.ExcelWriter.write(ExcelWriter.java:47)
at com.alibaba.excel.write.builder.ExcelWriterSheetBuilder.doWrite(ExcelWriterSheetBuilder.java:62)
at com.zto.ils.task.base.TaskHandler.buildExcelFile(TaskHandler.java:217)
at com.zto.ils.task.base.TaskHandler.upload(TaskHandler.java:129)
at com.zto.ils.task.base.ExportTaskHandler.process(ExportTaskHandler.java:87)
at com.zto.ils.task.base.TaskHandler.execute(TaskHandler.java:76)
at com.zto.ils.listener.TaskMessageListener.onMessageExport(TaskMessageListener.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.zto.titans.mq.configuration.ZMSMessageListenerImpl.onMessage(ZMSMessageListenerImpl.java:214)
at com.zto.titans.mq.configuration.ZMSMessageListenerImpl$$EnhancerByCGLIB$$8c2837a7.CGLIB$onMessage$2(<generated>)
at com.zto.titans.mq.configuration.ZMSMessageListenerImpl$$EnhancerByCGLIB$$8c2837a7$$FastClassByCGLIB$$2199b8b5.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244)
at com.zto.titans.common.plugin.Interceptor.intercept(Interceptor.java:28)
at com.zto.titans.common.plugin.Interceptor.intercept(Interceptor.java:30)
at com.zto.titans.logging.cat.mq.CatZMSMessageListenerInterceptor.intercept(CatZMSMessageListenerInterceptor.java:48)
at com.zto.titans.common.plugin.Interceptor.intercept(Interceptor.java:30)
at com.zto.titans.mq.configuration.ZMSMessageListenerImpl$$EnhancerByCGLIB$$8c2837a7.onMessage(<generated>)
at com.zto.consumer.KafkaConsumerProxy.lambda$submitRecords$15(KafkaConsumerProxy.java:449)
at com.zto.consumer.KafkaConsumerProxy$$Lambda$1514/1889443985.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)