将.xltx转换为.xlsx

我正在阅读.xltx,我想导出.xlsx。

protected static final String ruta = ResourcesPathEnum.ROOT.getId() + "plantillas" + File.separator; public static final String CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; protected abstract Workbook xlsx() throws FileNotFoundException, IOException; /** * Genera excel * * @return InputStream */ public InputStream getFile() { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { xlsx().write(bos); } finally { bos.close(); } return new ByteArrayInputStream(bos.toByteArray()); } catch (FileNotFoundException e) { Logger.error(e.getMessage()); } catch (IOException e) { Logger.error(e.getMessage()); } return null; } public StreamedContent getFile() { ControllerReportSuceso aux = new ControllerReportSuceso(suceso, sucesosAvionWrapper); return new DefaultStreamedContent(aux.getFile(), ControllerReportSuceso.CONTENT_TYPE, "parte suceso: " + suceso.getEntidad().getNumeroOrden() + ".xlsx"); } 

当我导出时,.xlsx在打开文件时总是给我一个错误, 因为格式或扩展名不正确Excel无法打开文件 。 如果我将扩展名更改为.xls,我可以打开它。

我正在使用POI 3.12。