easypoi大批量数据导出避免oom

//这个方法会被循环调用 page每次+1
			IExcelExportServer iExcelExportServer = (queryParams, page) -> {
				if (queryParams instanceof PageRequest) {
					PageHelper.startPage(page, CommonConstants.Number.TEN_THOUSAND_INTEGER);
					List<ConsultationWorkForceEntity> consultationWorkForceList = consultationWorkForceMapper.findAll(findWorkingScheduleDTO);
					if (CollectionUtils.isNotEmpty(consultationWorkForceList)) {
						List<WorkingScheduleListExport> exportList = new ArrayList<>();
						List<WorkingScheduleListVO> consultationWorkForceVoList = buildWorkingScheduleVO(consultationWorkForceList);
						for (WorkingScheduleListVO workingScheduleListVO : consultationWorkForceVoList) {
							WorkingScheduleListExport workingScheduleListExport = new WorkingScheduleListExport();
							StringBuilder builder = new StringBuilder();
							if (StringUtils.isNotBlank(workingScheduleListVO.getRoomName())) {
								builder.append(workingScheduleListVO.getRoomName());
							}
							if (StringUtils.isNotBlank(workingScheduleListVO.getVideoNumber())) {
								if (StringUtils.isNotBlank(workingScheduleListVO.getRoomName())) {
									builder.append(SymbolConstant.VIRGULE);
								}
								builder.append(workingScheduleListVO.getVideoNumber());
							}
							String roomName = builder.toString();
							if (StringUtils.isBlank(roomName)) {
								roomName = SymbolConstant.MIDLINE;
							}
							BeanUtils.copyProperties(workingScheduleListVO, workingScheduleListExport);
							workingScheduleListExport.setRoomName(roomName);
							exportList.add(workingScheduleListExport);
						}
						return new ArrayList<>(exportList);
					}
				}
				return null;
			};
			workbook = ExcelExportUtil.exportBigExcel(exportParams, WorkingScheduleListExport.class, iExcelExportServer, new PageRequest());
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
导出Excel时遇到OOM(Out of Memory)错误是因为内存不足导致的。在Java中,处理Excel的常用框架如Apache POI和jxl都存在内存消耗较大的问题。然而,有一个名为EasyExcel的框架可以解决这个问题。EasyExcel是一个快速、简单避免OOMJava处理Excel工具,它重写了POI对07版Excel的解析,能够将原本需要大量内存的Excel文件降低到几兆字节的内存消耗。对于大文件Excel,EasyExcel提供了SXSS模式,可以避免OOM错误的发生。你可以使用EasyExcel的IExcelWriter接口及其实现类来导出Excel文件,具体可以参考EasyExcel的文档和示例代码。\[2\]\[3\] #### 引用[.reference_title] - *1* *3* [java 导出 excel 最佳实践,java 大文件 excel 避免OOM(内存溢出) excel 工具框架](https://blog.csdn.net/weixin_34177064/article/details/88702493)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [JAVA导出exce大数据量发生OOM异常](https://blog.csdn.net/wang_yongchuan/article/details/110881449)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值