- 实体类包装
@ExcelTarget(value = "cmsDocumentMaster")
public class CmsDocumentMaster implements Serializable {
/*
* 文稿标题
*/
@Excel(name = "新闻标题", orderNum = "0")
private String masterTitle;
}
- 具体代码实现
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();