MyExcel 是一個集導入、導出、加密 Excel 等多項功能的 Java 工具包。
本次更新主要是BUG修復,更新點如下:
建議所有使用用戶儘快升級,更多請移步:https://github.com/liaochong/myexcel/wiki
--------------------------------------------------------------------------------------
導入示例:
URL htmlToExcelEampleURL = this.getClass().getResource("/templates/read_example.xlsx");
Path path = Paths.get(htmlToExcelEampleURL.toURI());
// 方式一:全部讀取后處理
List<ArtCrowd> result = DefaultExcelReader.of(ArtCrowd.class)
.sheet(0) // 0代表第一個,如果為0,可省略該操作
.rowFilter(row -> row.getRowNum() > 0) // 如無需過濾,可省略該操作,0代表第一行
.beanFilter(ArtCrowd::isDance) // bean過濾
.read(path.toFile());// 可接收inputStream
導出示例:
/**
* 普通方式導出
*/
@GetMapping("/default/excel/example")
public void defaultBuild(HttpServletResponse response) throws Exception {
List<ArtCrowd> dataList = this.getDataList();
Workbook workbook = DefaultExcelBuilder.of(ArtCrowd.class)
.build(dataList);
AttachmentExportUtil.export(workbook, "藝術生信息", response);
// 加密導出 AttachmentExportUtil.encryptExport(workbook, "藝術生信息", response,"123456");
}
效果:
[admin
]