当前位置:网站首页>EasyExcel实用技巧
EasyExcel实用技巧
2022-07-25 23:11:00 【等风来】
下载,上传excel
/** 模板下载(用的poi的) */
ClassPathResource resource = new ClassPathResource("template/企业信息模板.xlsx");
String path = resource.getURL().getPath();
path = URLDecoder.decode(path, "UTF-8");
File file = new File(path);
Workbook workbook = new XSSFWorkbook(file);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
workbook.write(response.getOutputStream());
/** 导出数据 */
@GetMapping("download")
public void download(HttpServletResponse response) throws IOException {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
EasyExcel.write(response.getOutputStream(), xx.class).sheet("模板").doWrite(List);
}
/** excel文件的上传 */
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file) throws IOException {
EasyExcel.read(file.getInputStream(), DemoData.class, new DemoDataListener()).sheet().doRead();
return "success";
}
读取数据
InputStream inputStream = multipartFile.getInputStream();
List<ExcelImportTktEntInfoVo> list = EasyExcel.read(inputStream).head(ExcelImportTktEntInfoVo.class).sheet().doReadSync();
注解
@ColumnWidth(30)
public class ExcelExportTktInfoVo {
@ExcelIgnore
private String esopEnterpriseId;
@ExcelProperty("地市")
private String busiRegCityName;
}
边栏推荐
- Experience of machine learning with Google Lab
- Custom MVC principle
- [PTA] 7-24 minimum fraction (15 points)
- 第二周学习:卷积神经网络
- PHP wechat scan code, follow official account and authorize login source code
- Data filtering of MATLAB
- [literature reading] - HRL -[hrl with universal policies for multi step robotic control]
- File contains vulnerability
- Network Security Learning (XIV) IP protocol
- wordpress去掉网站发布时间
猜你喜欢

serialization and deserialization

Network Security Learning (XII) OSI and TCP

Unity 使用宏

The fourth experiment nat

The VM session was closed before any attempt to power it on

自定义mvc原理

7-1 understand everything

firewall 命令简单操作

Drive board network cable directly connected to computer shared network configuration

Take away applet with main version of traffic / repair to add main access function of traffic
随机推荐
推荐系统——An Embedding Learning Framework for Numerical Features in CTR Prediction
Network Security Learning (11) scanning and blasting
The difference between "rewrite" and "overload"
Call Gaode map -- address is converted into longitude and latitude
Enterprise level inventory management system of code audit
HJ9 提取不重复的整数
Network Security Learning (XII) OSI and TCP
Take away applet with main version of traffic / repair to add main access function of traffic
Summary of my 2020 online summer camp
r语言绘图参数(R语言plot画图)
Secure code warrior learning record (IV)
What has Amazon cloud technology done right to become the leader of cloud AI services for three consecutive years?
Summary of traversal methods of six sets list, set, map, queue, deque and stack
PHP binary array is sorted by a field in it
WordPress controls the minimum and maximum number of words of article comments
Mongodb的特点、与MySQL的差别、以及应用场景
Notification(状态栏通知)详解
ETL工具(数据同步) 二
MES系统设备管理概述(下)
Explain in detail the addition (+) operation in JS, basic data type addition, reference data type addition, and the underlying operation rules, [] + {}, {} + []