当前位置:网站首页>internship:利用easypoi将excel表数据导入导出
internship:利用easypoi将excel表数据导入导出
2022-07-29 19:44: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;
.......
/** * 上传人员excel * * @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, "表格导入错误!");
}
//保存员工信息
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);
}
边栏推荐
- leetcode:952. 按公因数计算最大组件大小【并查集】
- 并发编程学习笔记 之 常用并发容器的概念及使用方法
- JSP Servlet JDBC MySQL CRUD 示例教程
- Monitoring basic resources through observation cloud monitor, automatic alarm
- ESP8266-Arduino编程实例-EEPROM读写
- JS实现倒计时代码实例「建议收藏」
- Private domain growth | Private domain members: 15 case collections from 9 major chain industries
- scratch 编程 + 小学数学
- C语言学习书籍(提高篇)
- 【AutoSAR 八 OS】
猜你喜欢

LeetCode #88.合并两个有序数组

Experience Sharing | Tips for Writing Easy-to-Use Online Product Manuals

【Autosar vLinkGen 链接器脚本生成器】

这半年我做交易链路自动化回归的那些事儿...

使用IDEA连接mysql

【目标检测】Generalized Focal Loss V2

MySQL 中的反斜杠 \\,怎么能这么坑?

updatexml、extractvalue和floor报错注入原理

ds1302——Bin brother 51

HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
随机推荐
ESP8266-Arduino编程实例-LittleFS及数据上传
学校安全管理专题培训实施方案
笛卡尔树(暑假每日一题 9)
leetcode:952. 按公因数计算最大组件大小【并查集】
如何使用TDengine Sink Connector?
【二叉树】好叶子节点对的数量
线程的六种状态
m10
【AutoSAR 五 方法论】
ACM学习书籍简介
这半年我做交易链路自动化回归的那些事儿...
MySQL 中的反斜杠 \\,怎么能这么坑?
updatexml、extractvalue和floor报错注入原理
使用IDEA连接mysql
ACM study book introduction
正则表达式
【Autosar vLinkGen 链接器脚本生成器】
要卖课、要带货,知识付费系统帮你一步搞定!
【技术课堂】从批到流:pull or not pull, that's a question
JSP Servlet JDBC MySQL CRUD 示例教程