String sheetName = "购物券入账记录";
req.setPageSize(10);
Page<JybGwqBill> billPage = jybGwqBillFacade.jybGwqEntryPage(req.toReq());
int pageNo = Convert.toInt((billPage.getTotal() - 1) / pageSize + 2);
try {
Workbook workbook = null;
ExportParams params = new ExportParams(null, sheetName);
workbook = ExcelExportUtil.exportBigExcel(params, JybGwqEntryExcel.class, new IExcelExportServer() {
@Override
public List<Object> selectListForExcelExport(Object obj, int page) {
if (((int) obj) == page) {
return null;
}
List<Object> list = new ArrayList<Object>();
req.setPageNo(page);
req.setPageSize(pageSize);
Page<JybGwqBill> jybGwqBillPage = jybGwqBillFacade.jybGwqEntryPage(req.toReq());
List<JybGwqBill> records = jybGwqBillPage.getRecords();
records.stream().forEach(e-> {
JybGwqEntryExcel item = new JybGwqEntryExcel();
BeanUtils.copyProperties(e, item);
list.add(item);
});
return list;
}
}, pageNo);
ServletOutputStream out = response.getOutputStream();
workbook.write(out);
out.flush();
out.close();
}catch (Exception e){
e.printStackTrace();
}
//依赖
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
easypoi分页导出
最新推荐文章于 2024-05-03 13:13:36 发布