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

Formula Cell - Save Formula and use outside of the grid

Hi,

I'm trying to evaluate if the Formula support in the Syncfusion grids would work for us...

I have a couple of I think fairly simple questions :)

1) If I make a cell a FormulaCell type, can I get both the value and the formula (as a string) from the cell somehow?
2) If I saved that formula, could I/how would I use it again in other Syncfusion products like reporting?

The idea is we have a product that does a lot of financial calculations.  At the moment, the design is a bit cumbersome because it takes lots of values, writes them to the db, does calculations, writes those to the db, and so on.  I'm trying to move to a position where we no longer store all the results of calculations, but rather the formulas, so we can recalculate at will.   However this would also mean we would need to be able to recalculate the formulas on other outputs, like reports/dashboards etc.

Kind regards,
Adam.

1 Reply

PM Piruthiviraj Malaimelraj Syncfusion Team March 1, 2017 01:59 PM UTC

Hi Adam, 
 
Thanks for your interest in Syncfusion products. 
 
Query 
Response 
 
 
 
 
 
 
 
 
If I make a cell a FormulaCell type, can I get both the value and the formula (as a string) from the cell somehow? 
The formula text and the result value can be get by using GridStyleInfo.CellValue and GridStyleInfo.FormattedText respectively. In the attached sample, the formula and the values are stored in a list. Please refer to the attached sample, 
 
Code example: 
List<SaveFormula> list; 
private void button1_Click(object sender, EventArgs e) 
{ 
    for (int r = 1; r <= this.gridControl1.RowCount; r++) 
    { 
        //Gets the CellStyle of FormulaCell. 
        GridStyleInfo cellStyle = this.gridControl1[r, 5]; 
        string formula = cellStyle.CellValue.ToString(); 
        object result = cellStyle.FormattedText; 
 
        //Store the Formula string and Result in a List. 
       list.Add(new SaveFormula(formula, result, r, 5)); 
    } 
} 
 
Sample link: 
If I saved that formula, could I/how would I use it again in other Syncfusion products like reporting? 
You can retrieve those  formulas from the saved List source and use it in where you want to use those formulas. Please let us know if you have any queries. 
 
Regards, 
Piruthiviraj

Loader.
Live Chat Icon For mobile
Up arrow icon