概述
@ApiOperation(value = "列表数据导出")
@PostMapping(value = "/preFollowListExport", produces = "application/json;charset=UTF-8")
public void export(HttpServletResponse servletResponse) throws IOException {
String name = "数据表";
servletResponse.setHeader("content-Type", "application/vnd.ms-excel");
servletResponse.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(name + ".xls", "utf-8"));
servletResponse.setHeader("Access-Control-Expose-Headers", "ContentDisposition");
//获取数据源
List<DataBean> list = null;
ExportParams params = new ExportParams(name, "sheet1");
Workbook workbook = ExcelExportUtil.exportBigExcel(params, DataBean.class, list);
ExcelExportUtil.closeExportBigExcel();
try {
workbook.write(servletResponse.getOutputStream());
}catch (IOException e) {
e.printStackTrace();
}finally {
workbook.close();
}
}
数据实体对象:
@Data
@ExcelTarget(value = "dataBean")
public class DataBean implements Serializable {
@Excel(name = "序号")
private Integer sortNum;
@Excel(name = "姓名")
private String name;
}
最后
以上就是健忘马里奥为你收集整理的easypoi导出excel表格数据的全部内容,希望文章能够帮你解决easypoi导出excel表格数据所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复