关注互联网应用及运维技术的个人博客

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();
赞(0)
未经允许不得转载:飞天狒狒 » easypoi导出大数据

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址