Closed n0rv1n closed 4 months ago
@n0rv1n Temporarily does not support the encryption of doc/xls/ppt files, please ask what scenarios need to be used, if it is really necessary, you can consider adding these features later!
//设置文件名
String fileName = DateFormatUtils.format(new Date(), "yyyyMMddHHmm") + "_" + sheetName + ".xls";
//设置输出头
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
response.setHeader("Content-Disposition",
"attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()));
//输出文件流
EasyExcelFactory.write(response.getOutputStream(), objectClass)
//单元格加密
.registerWriteHandler(new CustomSheetWriteHandler()).registerWriteHandler(new StyleWriteHandler())
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.autoCloseStream(Boolean.FALSE)
//excel文件加密
.password("123")
//设置输出格式
.excelType(ExcelTypeEnum.XLS)
//设置sheet名
.sheet(sheetName)
//输出数据
.doWrite(list);
Are there any way to encrypt doc/xls/ppt files?