easypoi导出大数据

  1. 实体类包装
@ExcelTarget(value = "cmsDocumentMaster")
public class CmsDocumentMaster implements Serializable {
    /*
     * 文稿标题
     */
    @Excel(name = "新闻标题", orderNum = "0")
    private String masterTitle;
}
  1. 具体代码实现
ExportParams params = new ExportParams("title", "title");
// list 数据自行获取
Workbook workbook = ExcelExportUtil.exportBigExcel(params, CmsDocumentMaster.class, list);
ExcelExportUtil.closeExportBigExcel();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setHeader("Content-Disposition", "attachment;fileName=title.xlsx");
OutputStream out = response.getOutputStream();
if (workbook != null) {
    workbook.write(out);
}
out.flush();
out.close();
# java  

评论

企鹅群:39438021

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×