当前位置:网站首页>Internship: use easypoi to import and export excel table data
Internship: use easypoi to import and export excel table data
2022-07-29 20:55:00 【ahyo】
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@TableName("employer")
public class BizEmployer extends Model<BizEmployer> {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/** * 姓名 */
@Excel(name = "姓名",width = 25)
private String name;
/** * 性别 */
private Integer sex;
@TableField(exist = false)
@ApiModelProperty(value="性别")
private String sexStr;
@TableField(exist = false)
@ApiModelProperty(value="年龄")
private String age;
@Excel(name = "身份证号",width = 25)
@TableField("id_card")
@ApiModelProperty(value="身份证号")
private String idCard;
.......
/** * uploaderexcel * * @param file * @return */
@RequestMapping(value = "/uploadExcel", method = RequestMethod.POST)
public ResponseData uploadExcel(HttpServletRequest request, MultipartFile file) {
ImportParams importParams = new ImportParams();
importParams.setTitleRows(1);
List<BizEmployer> result;
try {
result = ExcelImportUtil.importExcel(file.getInputStream(), BizEmployer.class, importParams);
} catch (Exception e) {
e.printStackTrace();
throw new BusinessException(500, "Table import error!");
}
//保存员工信息
if (ToolUtil.isEmpty(result)) {
throw new BusinessException(BizExceptionEnum.EXCEL_EMPTY);
}
List<BizEmployer> errorList = employerService.importExcel(result);
request.getSession().setAttribute("employerList", errorList);
return new ResponseData<>(errorList.size() == 0);
}
边栏推荐
猜你喜欢

C语言学习书籍(提高篇)

百度实习学弟深夜吐槽:原来大厂是这种生活啊

MATLAB程序设计与应用 2. 第2章 MATLAB数据及其运算 2.1 MATLAB数值数据 && 2.2 MATLAB矩阵的表示 && 2.3 变量及其操作

Web—信息收集(非常全)

JSP Servlet JDBC MySQL CRUD 示例教程

Private domain growth | Private domain members: 15 case collections from 9 major chain industries
![[数学基础]概率论与数理统计相关概念学习](/img/bc/d3a246240ff7aca2b84c3766383758.png)
[数学基础]概率论与数理统计相关概念学习

The ambition of glory: "high-end civilians" in a smart world

8.2实训任务 Sqoop的安装与配置

Thesis writing strategy | how to write an academic research paper
随机推荐
LOG4J Learning
Unity判断字符串是否可以转为float类型
【AutoSAR 八 OS】
荣耀的野望:智慧世界的“高端平民”
JMeter tutorial (a)
Flink1.15源码阅读flink-clients之GenericCLI、flinkYarnSessionCLI和DefaultCLI
论文写作全攻略|一篇学术科研论文该怎么写
如何把thinkphp5的项目迁移到阿里云函数计算来应对流量洪峰?
C语言学习书籍(提高篇)
模拟量、数字量与开关量的区别
【AutoSAR 十 IO架构】
GNOME将在Secure Boot被禁用时向用户发出警告 并准备提供安全帮助
程序员如何提升自己写代码的能力?
easyExce模板填充生成Excel的实际操作,多sheet页处理
Xcode如何利用预览(Preview)让SwiftUI视图快速适配不同尺寸的设备
4D Summary: 38 Knowledge Points of Distributed Systems
Build your own image search system (1): 10 lines of code to search images by image
Data visualization ---- web page displays temperature and humidity
悲伤的摇滚乐
并发编程学习笔记 之 常用并发容器的概念及使用方法