Free Support Forum - aspose.com

Calculate formula after re-setting formula in a cell using Aspose.Cells for .NET in C#

Hi,

I’m using Aspose.Cells 4.7.1.22. You find my testfile attached.

In cell A2 there is a formula"=(“Tabelle1!B”&ROW()-1)“
In my testfile I just reSet this formula to the same cell and try to calculate, but the string value isn’t correct.

please can you check this:


Cell c = workbook.Worksheets[0].Cells[“A2”];
// #1

// Get string value. OK

string value = c.StringValue;

// Re-Set Formula

c.Formula = c.Formula;

// Calc

workbook.CalculateFormula();

// StringValue = #Value!

string value2 = c.StringValue;


// #2

// ReSet Formula again

c.Formula = c.Formula;

// Calc again

workbook.CalculateFormula();

// StringValue= 8

string value3 = c.StringValue;


I have no problem with this formula without the “-1” at the end.
”=(“Tabelle1!B”&ROW())" works

<!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Normale Tabelle"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-fareast-language:EN-US;}

<![endif]–>

By the way.. is there any chance to calculate just one formula, not the hole workbook? something like

workbook.worksheets[0].Cells["A1"].CalculateFormula();

I'm not sure if it is possible?


Thank you

Hi,

Thanks for providing us template file with sample code.

We have found the issue as you have mentioned. We will fix it soon.

"By the way.. is there any chance to calculate just one formula, not the hole workbook? something like ....workbook.worksheets[0].Cells["A1"].CalculateFormula();"

We will check the feasibility of your demand and let you know soon.

Thank you.


Hi,

Please try the attached version, we have fixed it.

Thank you.

Fine, it works!

Thank you!

The issues you have found earlier (filed as CELLSNET-10036) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Note: Just for your knowledge. In the new release v4.8.0, we have merged Aspose.Grid suite to Aspose.Cells for .NET msi installer as Aspose.Grid would be no longer offered as a separate product now. You need to install the installer (uninstall older one first if you have) and use only Aspose.Cells.dll library in your project for your need. You may also take advantage using Aspose.Cells Grid suite though.