From 2f640b1038fa331954f78ed1f4317212cf5bb34d Mon Sep 17 00:00:00 2001 From: chenlu <1320612696@qq.com> Date: 星期五, 07 六月 2024 16:56:06 +0800 Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override --- north-glass-erp/src/main/java/com/example/erp/tools/DownExcel.java | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/north-glass-erp/src/main/java/com/example/erp/tools/DownExcel.java b/north-glass-erp/src/main/java/com/example/erp/tools/DownExcel.java new file mode 100644 index 0000000..8ab2fab --- /dev/null +++ b/north-glass-erp/src/main/java/com/example/erp/tools/DownExcel.java @@ -0,0 +1,22 @@ +package com.example.erp.tools; + +import com.alibaba.excel.EasyExcel; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +//exccel涓嬭浇 +public class DownExcel { + public static void download(HttpServletResponse response, Class t, List list,String reportName) throws IOException, IllegalAccessException,InstantiationException { + response.setContentType("application/vnd.ms-excel");// 璁剧疆鏂囨湰鍐呯渷 + response.setCharacterEncoding("utf-8");// 璁剧疆瀛楃缂栫爜 + response.setHeader("Content-disposition", "attachment;filename="+reportName+".xlsx"); // 璁剧疆鍝嶅簲澶� + try { + EasyExcel.write(response.getOutputStream(), t).sheet("妯℃澘").doWrite(list); //鐢╥o娴佹潵鍐欏叆鏁版嵁 + }catch (Exception e){ + System.out.println("鏂囦欢瀵煎嚭寮傚父"+reportName+":"+e.getMessage()); + } + + } +} -- Gitblit v1.8.0