use of com.ruoyi.common.excel.convert.ExcelBigNumberConvert in project RuoYi-Cloud-Plus by JavaLionLi.
the class ExcelUtil method exportExcel.
/**
* 导出excel
*
* @param list 导出数据集合
* @param sheetName 工作表的名称
* @return 结果
*/
public static <T> void exportExcel(List<T> list, String sheetName, Class<T> clazz, HttpServletResponse response) {
try {
String filename = encodingFilename(sheetName);
response.reset();
FileUtils.setAttachmentResponseHeader(response, filename);
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8");
ServletOutputStream os = response.getOutputStream();
EasyExcel.write(os, clazz).autoCloseStream(false).registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()).registerConverter(new ExcelBigNumberConvert()).sheet(sheetName).doWrite(list);
} catch (IOException e) {
throw new RuntimeException("导出Excel异常");
}
}
Aggregations