Search code examples
c#excelexcel-automation

Enable the Show Formulas in Excel from C# code


I am creating a windows application in C# .net to open an excel sheet and edit it. I am using excel automation in c# to do this.After editing/modifying some values in the sheet I will save the entire sheet in text file format. I am editing only one sheet and the sheet I am editing have formulas that have dependency on other sheet. So the formulas in the sheet are coming as #NAME?. When I save this excel sheet in .txt format I am getting the same error code instead of the formulas. I want the real formulas in my sheet and the text file.

Excel have an option to show the real formulas with the Formulas->Show Formulas.

I want the same to be done using the excel automation in c#

any suggestions


Solution

  • The method you are looking for is DisplayFormulas on the Window object. For example:

    ActiveWindow.DisplayFormulas = True