LoadOptions opt = new LoadOptions();
opt.setMemorySetting(MemorySetting.MEMORY_PREFERENCE);
Workbook workbook = new Workbook(new ByteArrayInputStream(excel), opt);
for (Object worksheet : workbook.getWorksheets()) {
PageSetup ps = ((Worksheet)worksheet).getPageSetup();
for (int i = 0; i < 3; i++) {
String rightFooterSection = ps.getFooter(i);
if(StringUtils.isNotBlank(rightFooterSection)){
rightFooterSection = rightFooterSection.replace("&F",title);
ps.setFooter(i, rightFooterSection);
}
}
}
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
workbook.save(outputStream, SaveFormat.XLSX);
报错日志:
2024-11-06 11:40:21.281 qys_53550d32-07de-4a11-aaa9-6e95b10b644f {http-nio-9180-exec-414} ERROR com.qiyuesuo.api.DocumentController 792 - 转换失败文件名称:附件:扬州大学2024年度省、校级研究生工作站立项名单和经费划拨一览表--表单.xls,失败信息:com.aspose.cells.b.a.d.u_ cannot be cast to com.aspose.cells.z5o
java.lang.ClassCastException: com.aspose.cells.b.a.d.u_ cannot be cast to com.aspose.cells.z5o
at com.aspose.cells.j6c.a(Unknown Source)
at com.aspose.cells.Workbook.getContentTypeProperties(Unknown Source)
at com.aspose.cells.k2.I(Unknown Source)
at com.aspose.cells.k2.s(Unknown Source)
at com.aspose.cells.k2.<init>(Unknown Source)
at com.aspose.cells.f6.b(Unknown Source)
at com.aspose.cells.b9q.b(Unknown Source)
at com.aspose.cells.f6.a(Unknown Source)
at com.aspose.cells.b9q.a_(Unknown Source)
at com.aspose.cells.Workbook.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)
at net.qiyuesuo.common.excel.ExcelUtils.handExcelFileNameMemoryPreference(ExcelUtils.java:230)