Spire.XLS for .NET is a professional Excel .NET library that can be used to any type of .NET( C#, VB.NET, ASP.NET, .NET Core) application, both ASP.NET web sites and Windows Forms application.

Wed Jan 26, 2011 6:25 am

In Excel worksheet, data is almost generated by formula. I want to get the formulas in cell so that I can edit them to my desired.
My query is how to display the formula that is hidden in cell with Spire.XLS?

Posts: 7
Joined: Tue Dec 21, 2010 9:01 am

Wed Jan 26, 2011 9:22 am

Thank you for your inquiry!
First we write a formula for a cell, and then we use sheet.Range.Text = sheet.Range.Formula method to write the formula. Following is the code:
Code: Select all
string currentFormula = string.Empty;
currentFormula = "=AVERAGE(Sheet1!$D$3:G$3)";
sheet.Range[1, 2].Formula = currentFormula;
sheet.Range[2, 2].Text = sheet.Range[1, 2].Formula;
e-iceblue support
User avatar

iceblue support
Posts: 240
Joined: Tue Dec 21, 2010 2:56 am

Return to Spire.XLS