Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Jan 26, 2011 6:25 am

Hi,
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?
THANKS!

ted
 
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