七月的小熊 2019-02-15 29864浏览量
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.2.5</version>
</dependency>
public class PersonDto {
/** id */
@ExcelProperty(index = 0 , value = "id")
private String id;
/** 姓名 **/
@ExcelProperty(index = 1 , value = "姓名")
private String name;
/** 生日 **/
@ExcelProperty(index = 2 , value = "生日" , format = "yyyy-MM-dd")
private String birth;
}
//单sheet输出
ExcelUtil.writeExcel(response, list, "导出测试", "sheet1", ExcelTypeEnum.XLSX);
//多sheet输出
ExcelUtil.writeExcel(response, "导出测试", ExcelTypeEnum.XLSX, list, list2);
//或
ExcelUtil.writeExcel(response, "导出测试", ExcelTypeEnum.XLSX, list, list2, list3);
List<FundDto> importDtoList = ExcelUtil.readExcel(excelFile,PersonDto .class);
@SheetName("sheet名称")
@Data
public class ExportTestModel {
@ExcelProperty(index = 0 ,value = "标题")
private String title;
}
原引入样式修改,后更新版本中增加了样式策略的修改,未引入
EasyExcel github地址:https://github.com/alibaba/easyexcel
EasyExcelUtils github项目地址:https://github.com/wangxiaoxiongjuly/easy-excel-utils
EasyExcelUtils gitee项目地址:https://gitee.com/wang-wen-xuan-july/easy-excel-utils
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
集结各类场景实战经验,助你开发运维畅行无忧