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.
Unfortunately, activation email could not send to your email. Please try again.

2 GridDataBoundGrid & A Syncfusion.Calculate.CalcEngine

Thread ID:

Created:

Updated:

Platform:

Replies:

75540 Jul 29,2008 07:20 PM Jul 30,2008 04:52 PM Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On July 29, 2008 07:20 PM

Hi ,

I Have 2 GridDataBoundGrids which uses a single Syncfusion.Calculate.CalcEngine.

After adding some formulas in those two girds , how can i get those formulas back by giving the Grid or GridName from the CalcEngine engine.

Regards,
Sreekesh NK


Administrator [Syncfusion]
Replied On July 29, 2008 07:35 PM

Here is one way you can do it. Add a hashtable to track the ICalcDataObjects as keys and the SheetNames as values. Populate this hashtable when you call RegisterGridAsSheet.


private Hashtable parentObjectToSheetName = new Hashtable();


//...

engine.RegisterGridAsSheet("DG1", this.dataGrid1, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid1, "DG1");
engine.RegisterGridAsSheet("DG2", this.dataGrid2, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid2, "DG2");
engine.RegisterGridAsSheet("DG3", this.dataGrid3, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid3, "DG3");
engine.RegisterGridAsSheet("DG4", this.dataGrid4, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid4, "DG4");
engine.RegisterGridAsSheet("DG5", this.dataGrid5, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid5, "DG5");
//...

//then to get the FormulaInfoTable, try code like this:

GridSheetFamilyItem family = CalcEngine.GetSheetFamilyItem(this.dataGrid1);

foreach (object key in engine.FormulaInfoTable.Keys)
{
FormulaInfo info = engine.FormulaInfoTable[key] as FormulaInfo;
string cell = key.ToString();
int loc = cell.LastIndexOf('!');
string sheetToken = cell.Substring(0, loc+1);
string sheetName = parentObjectToSheetName[family.TokenToParentObject[sheetToken]].ToString();
cell = cell.Substring(loc+1);
Console.WriteLine("sheet=[{0}] cell=[{1}] formula=[{2}]", sheetName, cell, info.FormulaText);
}



Administrator [Syncfusion]
Replied On July 30, 2008 04:52 PM

Hi ,
The code you have given is not working!!
Here also you are iterating through engine.FormulaInfoTable.Keys

foreach (object key in engine.FormulaInfoTable.Keys)

But this Keys is always the same irrespective of the grid.

I tired your code but it is not working.



>Here is one way you can do it. Add a hashtable to track the ICalcDataObjects as keys and the SheetNames as values. Populate this hashtable when you call RegisterGridAsSheet.


private Hashtable parentObjectToSheetName = new Hashtable();


//...

engine.RegisterGridAsSheet("DG1", this.dataGrid1, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid1, "DG1");
engine.RegisterGridAsSheet("DG2", this.dataGrid2, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid2, "DG2");
engine.RegisterGridAsSheet("DG3", this.dataGrid3, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid3, "DG3");
engine.RegisterGridAsSheet("DG4", this.dataGrid4, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid4, "DG4");
engine.RegisterGridAsSheet("DG5", this.dataGrid5, sheetfamilyID);
parentObjectToSheetName.Add(this.dataGrid5, "DG5");
//...

//then to get the FormulaInfoTable, try code like this:

GridSheetFamilyItem family = CalcEngine.GetSheetFamilyItem(this.dataGrid1);

foreach (object key in engine.FormulaInfoTable.Keys)
{
FormulaInfo info = engine.FormulaInfoTable[key] as FormulaInfo;
string cell = key.ToString();
int loc = cell.LastIndexOf('!');
string sheetToken = cell.Substring(0, loc+1);
string sheetName = parentObjectToSheetName[family.TokenToParentObject[sheetToken]].ToString();
cell = cell.Substring(loc+1);
Console.WriteLine("sheet=[{0}] cell=[{1}] formula=[{2}]", sheetName, cell, info.FormulaText);
}





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.

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.

;