Excel file became coruppted after saving

Could you explain to me what can be the reason why excel file become corrupted after saving?
Maybe there are some list of actions that make file corrupted?

@a.rodichev,
It is not possible to provide details without the sample file. Please share your sample Excel file, output Excel file, and sample code used for the conversion. Please ensure that you are using the latest version as we do not rectify issues in the previous versions.

AsposeCell bug.zip (53.5 KB)
Here are input and result files and code
And yes, I’m using last version ( 21.2)

@a.rodichev,

Please try our latest version/fix. Aspose.Cells for Java 21.6.x. I have tested with the latest fix:
Aspose.Cells for Java 21.6.7 (7.3 MB)
using the following sample code with your template file and it works fine. The output file is fine tuned and opened fine into MS Excel.
e.g.
Sample code:

Workbook workbook = new Workbook("f:\\Files\\Input.xls");
workbook.save("f:\\Files\\out1.xls", FileFormatType.EXCEL_97_TO_2003);

Let us know if you still find any issue with latest version/fix.

I tried to do it with 21.6.7 and have the same result
@Amjad_Sahi @ahsaniqbalsidiqui Do you have any other ideas, what can be the reason?

I don’t have any problems in most of cases. For example file that I attached here is saving fine.work fine.zip (10.4 KB)

@a.rodichev,

Could you please try my sample code (just change the file path accordingly) in previous reply and let us know your results:

Thanks! It works fine.
But what is the reason about corrupted file after rewriting it in the same file?

@a.rodichev,

It might be due to your code, so you may evaluate and fix it. It looks like your code does not specify your file as XLS and sets it to some other format type.

The line might be ambiguous and I am not sure about those variable/objects have what values:

workbook.save(file.getAbsolutePath(), fileType == EFileType.XLSX ? FileFormatType.XLSX : FileFormatType.EXCEL_97_TO_2003);

It is better you evaluate your issue by yourselves and fix it. If you still could not evaluate or think it is an issue with Aspose.Cells APIs, kindly create a simple console demo application (runnable - without compile time errors), zip the project and post us here, we will check and help you through.

PS. please exclude Aspose.Cells.Dll from the project to minimize the size of the zipped archive.