String fileName ="D:\test.xlsx";
ExcelWriter excelWriter = EasyExcel.write(fileName,TestVo.class).excelType(ExcelTypeEnum.XLSX)
.inMemory(false)
.autoCloseStream(false)
.build();
List objects = new ArrayList();
for (int i = 0; i < 110000; i++) {
TestVo testVo = new TestVo();
testVo.setSapCustomerCode(System.currentTimeMillis()+""+i);
testVo.setOrderGoodsDtlId("名字");
objects.add(testVo);
}
List testVoLists = Lists.partition(objects, 110000).stream().map(ArrayList::new).collect(Collectors.toList());
ForkJoinPool forkJoinPool = new ForkJoinPool(100, TtlForkJoinPoolHelper.getDefaultDisableInheritableForkJoinWorkerThreadFactory(), null, false);
forkJoinPool.submit(TtlRunnable.get(() -> testVoLists.parallelStream().forEach(m -> {
WriteSheet writeSheet = EasyExcel.writerSheet(0, "名字").head(TestVo.class)
.registerWriteHandler(new CustomCellWriteHandler()).registerWriteHandler(EasyExcelUtil.getStyleStrategy())
.build();
//写数据
WriteTable writeTable = new WriteTable();
excelWriter.write(m, writeSheet,writeTable);
}))).join();
excelWriter.finish();
1条答案
按热度按时间qq24tv8q1#