We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Not able to save on same file

Hi,


I am Not able to save any changes on same file. It will corrupt the file.
I have to save into different file.

I doing following things.

LoadOptions loadOptions = null;
FileStream excleFile= new FileStream(“C:\Book2.xls”, FileMode.Open);
loadOptions = new LoadOptions(LoadFormat.Auto);
Workbook workbook = new Workbook(fstream,loadOptions );

// adding new worksheet ,rename worksheet all other operations.

finally…

 workbook.Save(excleFile, SaveFormat.Xlsx);
 excleFile.Close();

It will save changes in file, but file become corrupted.

and next time when i open the file it will throws following error.

Cannot read that as a ZipFile

It works if I save as different file 
e,g workbook.Save(“C:\Book3.xls”, SaveFormat.Xlsx);

Any suggestion would appreciated !!!

Hi Ankur,


Thank you for contacting Aspose support.

We have evaluated your presented scenario while using the latest version of Aspose.Cells for .NET 8.3.1.3 and the following piece of code against a sample of our own. I am afraid, we are unable to observe any problem with the resultant spreadsheet when loaded back again in an instance of Workbook. MS Excel can also open the resultant spreadsheet, however, it shows a warning about the extension of the spreadsheet. This is because you are saving the result in XLSX format with incorrect extension (XLS).

C#

LoadOptions options = new LoadOptions(LoadFormat.Auto);
FileStream file = new FileStream(myDir + “1.xls”, FileMode.Open);
var book = new Workbook(file, options);
file.Close();

book.Worksheets[0].Name = “test”;
book.Worksheets.Add(“test 2”);
book.Save(myDir + “1.xls”, SaveFormat.Xlsx);

book = new Workbook(myDir + “1.xls”);

Please give the latest version of Aspose.Cells for .NET 8.3.1.3 (link shared above) a try on your end. In case the problem persists, please provide us your sample spreadsheet as well as the code snippet (executable) to replicate the said issue on our end.

Thank you so much for your help !!!

Hi Ankur,


I believe you are able to avoid the presented situation by upgrading the Aspose.Cells for .NET API to the latest version. Please feel free to write back in case you face any other difficulty or have more questions for us.