当前位置:网站首页>Practical skills of easyexcel
Practical skills of easyexcel
2022-07-25 23:20:00 【 wait for the wind】
download , Upload excel
/** Template download ( With poi Of ) */
ClassPathResource resource = new ClassPathResource("template/ Enterprise information 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());
/** Derived data */
@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(" Templates ").doWrite(List);
}
/** excel Upload of files */
@PostMapping("upload")
@ResponseBody
public String upload(MultipartFile file) throws IOException {
EasyExcel.read(file.getInputStream(), DemoData.class, new DemoDataListener()).sheet().doRead();
return "success";
}
Reading data
InputStream inputStream = multipartFile.getInputStream();
List<ExcelImportTktEntInfoVo> list = EasyExcel.read(inputStream).head(ExcelImportTktEntInfoVo.class).sheet().doReadSync();
annotation
@ColumnWidth(30)
public class ExcelExportTktInfoVo {
@ExcelIgnore
private String esopEnterpriseId;
@ExcelProperty(" Local market ")
private String busiRegCityName;
}
边栏推荐
- Unity 使用宏
- OASYS system of code audit
- anaconda安装教程环境变量(如何配置环境变量)
- Unity uses macros
- Bind class style and bind style style
- 类和对象(2)(6个默认成员函数)
- JS regular expression matches IP address (IP address regular expression verification)
- 网格参数化Least Squares Conformal Maps实现(3D网格映射到2D平面)
- 驱动板网线直连电脑共享网络配置
- QT add mouse event to control
猜你喜欢

Classes and objects (2) (6 default member functions)

驱动板网线直连电脑共享网络配置

How to set pseudo static for WordPress fixed links

firewall 命令简单操作

Solve the problem phpstudy failed to import the database

5 ROS仿真建模(3- rviz+gazebo+控制仿真机器人)

The fifth article in the series of radar Fundamentals: the function of radar modulation style

What has Amazon cloud technology done right to become the leader of cloud AI services for three consecutive years?

Enabling partners, how can Amazon cloud technology "get on the horse and get a ride"?

AI chief architect 12 AICA industrial landing analysis under the industrial production process optimization scenario
随机推荐
How does PHP remove an element from an array based on the key value
Servlet overview
General paging function
Tips for using (1)
Zcmu--5015: complete the task
TS function
Discuz atmosphere game style template / imitation lol hero League game DZ game template GBK
File contains vulnerability
TS class
Network Security Learning notes-1 file upload
How to set pseudo static for WordPress fixed links
CTS测试方法「建议收藏」
Summary of built-in instructions and custom instructions
Design of regular expressions
serialization and deserialization
连续三年成为云AI服务领导者,亚马逊云科技做对了什么?
ffmpeg初次学习(仅针对编码)
PHP wechat scan code, follow official account and authorize login source code
Discuz magazine / news report template (jeavi_line) utf8 GBK / DZ template download
wordpress去掉网站发布时间