Xlsx file are displaying file might be corrupted with latest aspose cells version

I have upgraded aspose cells from 19.10 to 24.11 then I am facing issues if I save the file in xlsx format it is displaying file might be corrupted.
The code I am using to save the workbook :
workbook.save(
stream, createSaveOptions(getSaveFormat(reportFile.getMimetype()), reportFile.isPdfA()));
private Integer getSaveFormat(String mimeType) {
return mapExtensionToSaveFormat(MimeType.mapMimeTypeToExtension(mimeType));
}
private int mapExtensionToSaveFormat(String extension) {
return switch (extension.toLowerCase()) {
case “xlsx” → SaveFormat.XLSX;
case “pdf” → SaveFormat.PDF;
case “html” → SaveFormat.HTML;
default → SaveFormat.UNKNOWN;
};
}
private SaveOptions createSaveOptions(Integer saveFormat, boolean isPdfA) {
SaveOptions options;
// Handle save options, special case for PDF/A
if (SaveFormat.PDF == saveFormat && isPdfA) {
com.aspose.cells.PdfSaveOptions pdfAOptions = new com.aspose.cells.PdfSaveOptions();
pdfAOptions.setCompliance(com.aspose.words.PdfCompliance.PDF_A_1_A);
options = pdfAOptions;
} else if (SaveFormat.PDF == saveFormat) {
options = new PdfSaveOptions();
} else if (SaveFormat.HTML == saveFormat) {
options = new HtmlSaveOptions(saveFormat);
} else {
final int format = saveFormat;
options = new com.aspose.cells.XlsSaveOptions(format);
}
public class XlsSaveOptions extends SaveOptions {
boolean a;

public XlsSaveOptions() {
    this.m_SaveFormat = 5;
}

public XlsSaveOptions(int saveFormat) {
    if (saveFormat == 32) {
        this.m_SaveFormat = 32;
    } else {
        this.m_SaveFormat = 5;
    }

}

This code worked for xlsx in 19.10 version of aspose cells

@harsha23,

Thanks for the code snippet.

How do you create the file? Are you using XlsSaveOptions to save the file in XLSX format? If so, please use OoxmlSaveOptions instead, as XlsSaveOptions is intended solely for the XLS format. If this isn’t the issue and you’re still encountering a corrupted file, please provide a sample runnable Java program (complete source code without compilation errors) along with the template Excel or other files (any input and output files) so we can replicate the problem on our end. We will then investigate it promptly.

@amjad.sahi Thanks for the response this worked with OoxmlSaveOptions

@harsha23
I’m glad your problem has been resolved! If you have any other questions, please feel free to contact us。