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. Image for the cookie policy date

CalcQuickBase with variables and sheet

Hi, i want to use calculate in my project.
Imagine a task that contains task-items that contains list of functions or formulas.
I want user always use variables names in formulas and functions.
Every task-items must be a sheet, because i want one task-item refer another.

I think i need to create one CalcQuickBase to each task-items and register with CalcEngine, and mantain a single Dictionary syncronized with each CalcQuickBase.

Anyone have a example for this ?

Thanks

5 Replies

MG Mohanraj Gunasekaran Syncfusion Team November 2, 2018 12:51 PM UTC

Hi Sergio, 
 
Thanks for using Syncfusion product. 
 
To use the multiple CalcQuickBase to calculate that reference value in another CalcQuickBase, you could use the RegisteerGridAsSheet method to register the formula and the you can use that cell reference with sheet name in computation. Please refer the following code example and the UG link, 
 
Code example 
//Initialization of first ICalcData object in CalcEngine, 
calcData = new CalcData(); 
CalcEngine engine = new CalcEngine(calcData); 
 
//Initialization of second ICalcData object in CalcEngine, 
calcData1 = new calcData1(); 
engine = new CalcEngine(calcData1); 
 
//Create a unique family id, 
int i = CalcEngine.CreateSheetFamilyID(); 
 
//Register the first ICalcData object as "Sheet1", 
engine.RegisterGridAsSheet("Sheet1", calcData, i); 
 
//Register the second ICalcData object as "Sheet2", 
engine.RegisterGridAsSheet("Sheet2", calcData1, i); 
 
//Access the two sheet references in the formula, 
string formula = “SUM(Sheet1!A1, Sheet2!A1)”; 
 
//Computation of result, 
string result = engine.ParseAndComputeFormula(formula); 
 
 
 
Regards, 
Mohanraj G 



CA Carbonete November 2, 2018 06:03 PM UTC

Hi Moranj

This not work to CalQUickBase.

If run  code attached , you receive a error "System.ArgumentException: 'An item with the same key has already been added. Key: Syncfusion.Calculate.CalcQuickBase'
"

//Initialization of first ICalcData object in CalcEngine,
            CalcQuickBase calcData = new CalcQuickBase();
            CalcEngine engine = new CalcEngine(calcData);
            calcData["A"] = "5";
            calcData["B"] = "6";
            calcData["C"] = "11";

            string result1 = calcData.ParseAndCompute("[A]+[B]+[C]");
            //Initialization of second ICalcData object in CalcEngine,
            CalcQuickBase calcData1 = new CalcQuickBase();
            engine = new CalcEngine(calcData1);
            calcData1["A"] = "6";
            calcData1["B"] = "6";
            calcData1["C"] = "6";
            string result2 = calcData1.ParseAndCompute("SUM([A],[B],[C])");
            calcData1["Result"] = result2;

            //Create a unique family id,
            int i = CalcEngine.CreateSheetFamilyID();

            //Register the first ICalcData object as "Sheet1",
            engine.RegisterGridAsSheet("Sheet1", calcData, i);

            //Register the second ICalcData object as "Sheet2",
            engine.RegisterGridAsSheet("Sheet2", calcData1, i);

            engine.SupportsSheetRanges = true;

            string result = engine.ParseAndComputeFormula("= SUM(Sheet1![A],Sheet1![B],Sheet1![C],Sheet2![Result]");

thanks



DY Deivaselvan Y Syncfusion Team November 5, 2018 06:31 PM UTC

Hi Sergio, 

Thanks for your update. 

We have prepared the simple sample by using CalcQuickBase. Please find the attached sample and let us know if you have any queries, 

Sample link: 

Regards, 
Deivaselvan 



CA Carbonete replied to Deivaselvan Y November 6, 2018 06:26 PM UTC

Hi Sergio, 

Thanks for your update. 

We have prepared the simple sample by using CalcQuickBase. Please find the attached sample and let us know if you have any queries, 

Sample link: 

Regards, 
Deivaselvan 


Thanks , very instructive


AA Arulraj A Syncfusion Team November 7, 2018 05:52 AM UTC

Hi Sergio,  

Thanks for your update. 

We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 

Regards, 
Arulraj A 


Loader.
Live Chat Icon For mobile
Up arrow icon