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

Get value from formula

Hi,
Sorry but i didnt find this anywere, so I need to ask you what I need to do to retreave the result of a formula via Javascript.

 var obj = $("#Spreadsheet").ejSpreadsheet('instance');
  obj.XLEdit.getPropertyValue(6,4); // returns "=SUM(E5:E6)"
obj.getCell(6,4); // return the cell html element

But I need the actual value of the E5 + E6

Please give me the answer.
Best Regards


3 Replies

SK Shanmugaraja K Syncfusion Team May 16, 2017 07:01 AM UTC

Hi Bruno, 
 
Thanks for using Syncfusion products. 
 
We would like to let you know that we suggest you to use pass “value2” or "calcValue" to getPropertyValue method to get the result of the formula. Please refer the below code example, 
 
[JS] 
 
         
       $(function () { 
            $("#Spreadsheet").ejSpreadsheet({ 
                // Rendering Spreadsheet 
            }); 
        }); 
 
        function Result() { 
            var xlObj = $('#Spreadsheet').ejSpreadsheet('instance'); 
            // B2 cell has formula =CONCATENATE("one","big") and result is "onebig". 
            alert("The Formula " + xlObj.XLEdit.getPropertyValue(1, 1, "value") + " result is: " + xlObj.XLEdit.getPropertyValue(1, 1, "value2")); 
        } 
 
        <input type="button" value="Formula Result" onclick="Result()" /> 
        <div id="Spreadsheet"></div> 
 
 
 
 
Please refer the below documentation and JSPlayground link, 
 
 
Regards, 
Shanmugaraja K 



BF Bruno Figueiredo May 16, 2017 10:37 AM UTC

Hi,
Well I totaly missed that.
Problem solved.

But allow me to sugest something,
I think you should simplify your function names. like:
XLEdit.getCellValue(x,y) and getFormulaValue(x,y) or getCellCalcValue(x,y)

Or something else, I don't know, but be more intuitive.


Thank You,
and thank you again for the fast reply



SK Shanmugaraja K Syncfusion Team May 18, 2017 09:47 AM UTC

Hi Bruno, 
 
Thanks for your suggestion, we have an option to get the formula cell value. If we add the separate methods like getting cell value and getting formula cell value, it may increase the size of the source. Since, we have lot of methods in our ejSpreadsheet control.  
 
Regards, 
Shanmugaraja K 


Loader.
Live Chat Icon For mobile
Up arrow icon