We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Named Formulas in Syncfusion.Calculate

Thread ID:

Created:

Updated:

Platform:

Replies:

71962 Feb 22,2008 02:51 PM UTC Mar 14,2008 02:53 PM UTC WinForms 2
loading
Tags: Calculate
James Grimes
Asked On February 22, 2008 02:51 PM UTC

In Syncfusion.Calculate, I would like to be able to add named formulas with formulas that reference a grid/datatable and potentially other named formulas. For example...

engine.AddNamedRange("myName", "SUM(grid1!A1:A10) + myOtherName")

I could not find an example of the above using Calculate. Can someone provide an example?


James Grimes
Replied On February 23, 2008 04:03 AM UTC

>In Syncfusion.Calculate, I would like to be able to add named formulas with formulas that reference a grid/datatable and potentially other named formulas. For example...

engine.AddNamedRange("myName", "SUM(grid1!A1:A10) + myOtherName")

I could not find an example of the above using Calculate. Can someone provide an example?



I am currently using the following code...

##### CODE #####

private CalcEngine engine;
private DataTable dt;

private void button1_Click(object sender, EventArgs e)
{
this.dt = GetDataTable();
this.dataGrid1.DataSource = this.dt;

CalcEngine.ResetSheetFamilyID();
engine = new CalcEngine(this.dataGrid1);

engine.AddNamedRange("TestVal", "SUM(C1:C3)");

engine.UseDependencies = true;
engine.RecalculateRange(RangeInfo.Cells(1, 1, dt.Rows.Count,
dt.Columns.Count), this.dataGrid1);

label1.Text = engine.ParseAndComputeFormula("TestVal");
}

################

The value in label1.Text is correct. The ParseAndComputeFormula works fine. However, if I have a cell in dataGrid1 that contains the formula "=TestVal", an object reference error is thrown.

What am I missing?


Anonymous
Replied On March 14, 2008 02:53 PM UTC

Here is our DataGrid sample modified to show

engine.AddNamedRange("TestVal", "SUM(C1:C3)"); //<<<<<<< added

when you type testval into the Textbox and also when you type =testval cell A1.

The only thing I see different than the code you listed is that

engine.RegisterGridAsSheet("SingleGrid", this.dataGrid1, sheetfamilyID);

is in the sample and not in the code you showed.



CS.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;