- 引入依赖包
<dependency>
<groupId>com.github.stupdit1t</groupId>
<artifactId>poi-excel</artifactId>
<version>3.3.0</version>
</dependency>
- commons工具类的版本必须在2.11以上<commons.io.version>2.11.0</commons.io.version>
- 导出代码
ExcelHelper.opsExport(PoiWorkbookType.BIG_XLSX)
.opsSheet(list)
.sheetName("sheet1")
.opsHeader().simple().texts("id", "商品名称", "商品简介", "商品状态", "商品价格", "成本价", "会员卡商品购买价格", "是否参加会员卡").done()
.opsColumn().fields("id", "goodsname", "subtitle")
.field("grounding")
.fields("price", "costprice", "cardPrice")
.field("isTakeVipcard").map((val, row, style, rowIndex) -> {
if (val.equals("1")) val="参加";
else val="不参加";
return val;
})
.done()
.export("E:\\商品.xlsx");