I’m working on an application that adds some data to an excel sheet and then saves the excel document as a stream that is stored for later use. I experience an issue when I download the file after saving. I see “_XLNF” prepended to a function (FORMULATEXT) within a formula that is on a sheet which I am not editing. I can resolve the issue by opening the downloaded file, clicking within the cell that has the corrupted formula, and pressing enter.
I looked into this issue a bit and found that the _XLNF text is prepended to functions that are not supported by excel. I am using Office 365 and excel 2016 so I do not believe the issue is on our end. On top of that, the formula looks fine when I store and download the sheet without calling the save function.
Here is a snippet of the offending code:
Workbook workbook = new Workbook(excelStream); workbook.Worksheets["OtherDataSheet"].Cells["A2"].Formula = "=MydataSheet!A1"; workbook.Worksheets["OtherDataSheet"].Cells["A2"].Calculate(new CalculationOptions()); var ms = new MemoryStream(); workbook.Save(ms, SaveFormat.Xlsm); //Reset the stream position so that it can be used later ms.Position = 0;
Here is what the formula looks like in the excel document before I use the snippet above:
And here it is after:
Do you have any insight on what may be causing the issue and potential steps to resolve it?
Thank you for your help!
NOTE: Aspose Cells for .NET version 18.4.0 in use.