当前位置:网站首页>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);
}
边栏推荐
猜你喜欢
![[Mathematical Foundation] Learning about concepts related to linear algebra](/img/4c/d43fb47ff5b99998660a679b20699c.png)
[Mathematical Foundation] Learning about concepts related to linear algebra

【体系结构 三 流水线技术】

Kubernetes: (4) Common commands

Is Apifox free?Completely free, unlimited team size, unlimited functions

conda虚拟环境 | install 与 list 问题

There is a fee for the picture bed software. Forget it, I wrote an open source free one.

如何把thinkphp5的项目迁移到阿里云函数计算来应对流量洪峰?

腾讯安全发布 Tencent Cloud EdgeOne,为企业出海打造安全加速一体化服务

【AutoSAR 十二 模式管理】

单核浏览器和双核浏览器有什么区别,哪个好用?
随机推荐
正则表达式
荧光量子点修饰siRNA-QDs|纳米金修饰siRNA-Au(RNA修饰方式方法)
Web—信息收集(非常全)
Expert advice | How to formulate a growth strategy for survival in an economic downturn
【AutoSAR 十三 NVM】
经验分享|编写简单易用的在线产品手册小妙招
HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
【AutoSAR 十一 通信相关机制】
震荡波病毒原代码(勒索病毒源代码)
Safe Browser will have these hidden features that will let you play around with your browser
【体系结构 一 概述】
【AutoSAR 七 工具链简介】
荣耀的野望:智慧世界的“高端平民”
使用MD5加密后的字符串存密码安全吗?你不得不了解的Hash算法
一道菜撑起百亿估值的太二酸菜鱼,能否迈过食品安全这道坎?
小学弟问:程序员的工作是不是每天都是敲一天的代码呢?
常用电源符号含义分享
Chrome——插件推荐
百度实习学弟深夜吐槽:原来大厂是这种生活啊
Monitoring basic resources through observation cloud monitor, automatic alarm