This is a migrated thread and some comments may be shown as answers.

Get Calculated Value

3 Answers 343 Views
Spreadsheet
This is a migrated thread and some comments may be shown as answers.
DM
Top achievements
Rank 1
DM asked on 09 May 2017, 01:25 PM

I have a spreadsheet with some formula (es. =A1*B2/5).

So I get the Json data and I see that something like that

{
      "name": "Sheet1",
      "rows": [
        {
          "index": 31,
          "cells": [
            {
              "value": 5,
              "format": "#",
              "index": 1
            },
            {
              "value": 10,
              "formula": "B32*2",
              "index": 2
            }
          ]
        }

is it possibile to use the js to get the calulated data or exist a .net dll to convert js"excel" style formula to data?

3 Answers, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 11 May 2017, 05:54 AM
Hi Mattia,

In the exported JSON, the calculated value of the cell will be available in the value field for that respective cell. In the JSON sample, that you have sent, the value of the cell with formula B32*2 is 10.

Here you will find a small sample demonstrating how such cell value could be retrieved using JS:
var spread = $("#spreadsheet").data('kendoSpreadsheet');
var sheet = spread.activeSheet();
var range = sheet.range('F15');
var value = range.value();

Note, that the above uses methods from the API of the Spreadsheet, the Spreadsheet Sheet and the Spreadsheet Range objects.

Regards,
Veselin Tsvetanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Marat
Top achievements
Rank 1
answered on 30 Dec 2020, 09:37 AM

Hi! Now I using some cell to calculate value like this:

    var spread = $("#spreadsheet").data('kendoSpreadsheet');
    var sheet = spread.activeSheet();
    var range = sheet.range('A3');
    var formula = range.formula("C5+1/96");
    var value = range.value();
    console.log(value);

But I want to take value without using cell. Can I use some funtion to do it like this:

var value = sheet.GetResultValue("C5+1/96");

0
Veselin Tsvetanov
Telerik team
answered on 30 Dec 2020, 01:52 PM

Hello Marat,

I am afraid formulas and their calculated values could not be extracted to be used without a target cell (range). Therefore, the approach that you are already following would be the appropriate one.

Regards,
Veselin Tsvetanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Spreadsheet
Asked by
DM
Top achievements
Rank 1
Answers by
Veselin Tsvetanov
Telerik team
Marat
Top achievements
Rank 1
Share this question
or