赞
踩
需求:实现excel文件导入并进行数据处理
实体类的设计:
用于上传的excel------------------------> WxdhCustomGenerateTaskExcel (名字随便起,言简意赅)
经过excelListener处理后的----------> WxdhCustomGenerateTaskResultExcel (同上)
Listener ----------------------------------> WxdhCustomGenerateTaskListener (同上)
------------------------------------------------------------------------------------------------------------------------
Excel内数据格式如下
tip:这里有个注意点,当你的数据很大,excel会自动进行数据科学计数法,读入excel的时候会报以下错误:"Convert excel format exception.You can try specifying the 'excelType' yourself"
解决办法:将Excel数据会变化的那列设置为文本,注意不要直接Ctrl+s保存,要另存为一个新文件,然后再打开,设置的文本格式就不会消失了。直接保存的话再打开设置的格式会还原。
- @Data
- public class WxdhCustomGenerateTaskExcel implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @ExcelProperty(value = "序号", index = 0)
- private String order;
-
- @ExcelProperty(value = "id", index = 1)
- private String id;
-
- @ExcelProperty(value = "age", index = 2)
- private String age;
-
-
- }

-----------------------------------------------------------------------------------------
- @Data
- public class WxdhCustomGenerateTaskResultExcel implements Serializable {
- private static final long serialVersionUID = 1L;
-
- private String order;
- private String id;
- private String age;
- private String name;
- private String class;
- /**
- * 是否有数据为空
- */
- private String empty;
-
- /**
- * 是否存在问题 (0-no 1-yes)
- */
- private Integer existQuestion;
-
- }

-------------------------------------------------------
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。