Unsaved changes pop up when closing newly created xlsx file


#1

Hi,

I convert the attached spreadsheetML to xlsx format using the code below. Then I open the document in Excel, do nothing, close it and then the popup appears that there are unsaved changes asking me if I want to save it.

var loadOptions = new LoadOptions( LoadFormat.SpreadsheetML );
var workbook;
using ( var stream = new FileStream( path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ) )
{
workbook = new Workbook( stream, loadOptions);
}

var saveOptions = new XlsSaveOptions( SaveFormat.Xlsx );
_workbook.Save( outputPath, saveOptions );

Could you please tell me what could cause this?

Please find the spreadsheetML attached.
ML_Sum.zip (1.0 KB)

Thanks,
Ewa


#2

@acturisaspose

This problem happens because Microsoft Excel recalculates the output Excel file on opening and on saving. So please use this code and set both properties as false. It should fix your issue.

C#

Workbook wb = new Workbook("ML_Sum.xml");
wb.Settings.RecalculateBeforeSave = false;
wb.Settings.ReCalculateOnOpen = false;

#3

Hi,

it does fix the issue for the simple example I sent, but unfortunately it doesn’t fix our more complex case. Please find the other spreadsheet ML attached.

ClaimsFormulas.zip (3.2 KB)

Thanks,
Ewa


#4

@acturisaspose

Thanks for your posting and using Aspose APIs.

We were able to observe this issue as per your description and logged it in our database for investigation and for a fix. Once, the issue is resolved or we have some other news for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-45572 - Opening and closing Output Excel file in Microsoft Excel pops up the message to save changes

#5

@acturisaspose,

Please call Workbook.CalculateFormula() method before as there are no values of some formulas in the xml file:
e.g
Sample code:

Workbook workbook = new Workbook(dir + "ClaimsFormulas.xml");
            workbook.Settings.RecalculateBeforeSave = false;
            workbook.Settings.ReCalculateOnOpen = false;
            workbook.CalculateFormula(); 

Let us know if you still have any issue.

Thank you.