项目上线了,结果导出数据时发现只能导出6w条,好奇怪啊...
本地试了试结果每次都卡在10w条. orz
开始扒拉批量导出
ExcelBatchExportServer server = new ExcelBatchExportServer();
server.init(exportParams,TTransLine.class);
server.write(exportList);
Workbook workbook = server.get();
奇了怪了,超过10w条创建了新的sheet
回来看看源码....额...额...
最终只要稍作修改..完事...
List<TT> exportList = new ArrayList<>();
int pageSize = 10000;
long pageMax = (count / 10000) + 1;
for (int i = 0; i < pageMax; i++) {
queryWrapper.last(" limit " + i * pageSize + "," + pageSize);
List<TT> pageList = tTService.list(queryWrapper);
if (pageList != null) {
exportList.addAll(pageList);
}
}
// Step.3 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//此处设置的filename无效 ,前端会重更新设置一下
mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.CLASS, TT.class);
ExportParams exportParams = new ExportParams(title + "报表", "导出人:" + sysUser.getRealname(), title);
// -------------关键代码--
exportParams.setType(ExcelType.XSSF);
// -------------关键代码--
exportParams.setImageBasePath(upLoadPath);
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
return mv;