use of com.alibaba.excel.write.handler.WriteHandler in project diboot by dibo-software.
the class ExcelHelper method writeDynamicData.
/**
* 简单将数据写入excel文件
* <p>默认列宽自适应数据长度, 可自定义</p>
*
* @param filePath
* @param sheetName
* @param dataList
* @param writeHandlers
* @return
*/
@Deprecated
public static boolean writeDynamicData(String filePath, String sheetName, List<List<String>> dataList, WriteHandler... writeHandlers) throws Exception {
try {
ExcelWriterBuilder write = EasyExcel.write(filePath);
write = write.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy());
for (WriteHandler handler : writeHandlers) {
write = write.registerWriteHandler(handler);
}
ExcelWriterSheetBuilder sheet = write.sheet(sheetName);
sheet.doWrite(dataList);
return true;
} catch (Exception e) {
log.error("数据写入excel文件失败", e);
return false;
}
}
Aggregations