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

CalcQuickBase with variables and sheet

Thread ID:

Created:

Updated:

Platform:

Replies:

140694 Nov 1,2018 06:18 PM UTC Nov 7,2018 05:52 AM UTC Xamarin.Forms 5
loading
Tags: Calculate
Carbonete
Asked On November 1, 2018 06:18 PM UTC

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

Mohanraj Gunasekaran [Syncfusion]
Replied On 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 


Carbonete
Replied On 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


Deivaselvan Y [Syncfusion]
Replied On 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 


Carbonete
Replied On 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

Arulraj A [Syncfusion]
Replied On 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 


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

;