Browse Source

2024-02-18 修改成大数据方式的excel文件导出,支持xlsx,数据列大于256

develop
zhousq 9 months ago
parent
commit
08e93b7fc6
  1. 6
      lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiHisReportController.java

6
lzbi-module/src/main/java/com/lzbi/bi/controller/DcBusiHisReportController.java

@ -3,6 +3,7 @@ package com.lzbi.bi.controller;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.BigExcelWriter;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.alibaba.fastjson2.JSONObject;
@ -244,10 +245,11 @@ public class DcBusiHisReportController extends BaseController {
}
private void toExcel(HttpServletResponse response,List<Map<String, Object>> mapList) throws IOException {
String fileName ="report"+DateUtil.now() + ".xls";
String fileName ="report"+DateUtil.now() + ".xlsx";
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
ExcelWriter writer = ExcelUtil.getWriter(true);
//ExcelWriter writer = ExcelUtil.getWriter(true);
BigExcelWriter writer= ExcelUtil.getBigWriter();
writer.write(mapList, true);
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
//response.setHeader("Content-Disposition", "attachment;filename="+fileName);

Loading…
Cancel
Save