原 easyexcel(二十五):easyexcel导出并设置密码
版权声明:本文为博主原创文章,请尊重他人的劳动成果,转载请附上原文出处链接和本声明。
本文链接:https://www.91mszl.com/zhangwuji/article/details/1476
@GetMapping("/download")
public void download(HttpServletResponse response) throws IOException {
String fileName = System.currentTimeMillis() + ".xlsx";
response.reset();
response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
OutputStream os=response.getOutputStream();
List<UserInfo> dataList=new ArrayList<>();
UserInfo u1=new UserInfo();
u1.setName("张无忌");
u1.setAge(18);
u1.setAddress("上海火车站");
UserInfo u2=new UserInfo();
u2.setName("赵敏");
u2.setAge(18);
u2.setAddress("上海火车站");
dataList.add(u1);
dataList.add(u2);
List<List<String>> headList=new ArrayList<>();
headList.add(Lists.newArrayList("姓名"));
headList.add(Lists.newArrayList("年龄"));
headList.add(Lists.newArrayList("地址"));
EasyExcel.write(os).head(headList).password("91mszl").sheet("用户信息").doWrite(dataList);
}
2024-02-06 15:15:25 阅读(337)
名师出品,必属精品 https://www.91mszl.com
博主信息