当前位置:网站首页>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);
}
边栏推荐
猜你喜欢

Private domain growth | Private domain members: 15 case collections from 9 major chain industries

ds1302——Bin brother 51

荧光量子点修饰siRNA-QDs|纳米金修饰siRNA-Au(RNA修饰方式方法)

Data visualization ---- web page displays temperature and humidity

EasyExce template filling generation of Excel of actual operation, many processing sheet page

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

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

数据可视化----网页显示温湿度

第二增长曲线 | 企业创新突破停滞困境的驱动指南

HMS Core音频编辑服务音源分离与空间音频渲染,助力快速进入3D音频的世界
随机推荐
正则表达式
easyExce模板填充生成Excel的实际操作,多sheet页处理
ACM study book introduction
[Mathematical Foundation] Learning about concepts related to linear algebra
腾讯安全发布 Tencent Cloud EdgeOne,为企业出海打造安全加速一体化服务
uri与url的区别简单理解(uri和url有什么区别)
There is a fee for the picture bed software. Forget it, I wrote an open source free one.
《帧同步教程一》定点数原理和无损精度的实现方式
ESP8266-Arduino programming example-I2C device address scan
尿素偶联Urea-siRNA Conjugates|Cyclodextrin-siRNA-β-CD环糊精修饰RNA核酸(解析说明)
这半年我做交易链路自动化回归的那些事儿...
常用电源符号含义分享
【体系结构 四 存储结构】
核壳二氧化钛纳米颗粒修饰DNA|二氢杨梅素修饰DNA药物|相关介绍
JUC并发编程基础AQS
[Binary tree] The number of good leaf node pairs
Thesis writing strategy | how to write an academic research paper
接口测试工具之Postman详解
Summary of scratch learning related materials
朴素贝叶斯“朴素”在哪里?