NEW VERSION RELEASED! Webix 11 Read More Core Updates, Extended Functionalities in SpreadSheet and File Manager and more

Math, JavaScript Programming Example of Math in SpreadSheet

JavaScript Programming Example of Math in SpreadSheet

You can effortlessly enable math calculations in SpreadSheet. Check out a coding sample below showing how to do it. You can download and use this programming example for free.

JS Code

webix.ui({
  view:"spreadsheet",
  toolbar:"full",
  data:{ 
    sheets: math_data 
  }
});

HTML Code

<script>
  var math_data = [
    {
      "name":"Report",
      "content": {
        "sizes":[
          [0,2,407],
          [0,4,207],
          [4,0,115]
        ],
        "styles":[
          ["wss1",";;;;;;;;;wrap;;;;;;"],
          ["wss2",";;;;;;;;;nowrap;;;;;;"],
          ["wss3",";;;;;;;;;;;percent;;;;"]
        ],
        "data":[
          [2,2,"You can fill charts and dropdowns from a different sheet","wss2"],
          [2,3,"","wss2"],
          [2,4,"Germany",""],
          [2,5,"","wss2"],
          [2,6,"","wss2"],
          [2,7,"","wss2"],
          [2,8,"","wss2"],
          [2,9,"","wss2"],
          [2,10,"","wss2"],
          [4,2,"=SPARKLINE(Countries!DATA,\"splineArea\",\"#6666FF\")",""],
          [7,2,"You can use values and ranges from different sheets",""],
          [8,3,"value",""],
          [8,4,"=Countries!A4 & \" \" &  Countries!B4 & \"mil\"",""],
          [9,3,"range",""],
          [9,4,"=SUM(Countries!B2:B3)",""],
          [10,3,"named range",""],
          [10,4,"=SUM(Countries!DATA)",""],
          [13,2,"You can reference formula results from different sheets",""],
          [13,3,"base",""],
          [13,4,"2",""],
          [14,3,"result",""],
          [14,4,"=Data!B8*D13","wss3"]
        ],
        "editors":[
          ["2","4",{"editor":"richselect","options":"Countries!NAMES"}]
        ]
      }
    },
    {
      "name":"Data",
      "content":{
        "styles":[
          ["wss1",";;;;;;;;;wrap;;;;;;"],
          ["wss2",";;;;;;;;;nowrap;;;;;;"]
        ],
        "spans":[
          [8,3,4,1]
        ],
        "data":[
          [2,2,"1",""],
          [2,3,"=B2*2+1",""],
          [3,2,"=C2*3-2",""],
          [3,3,"=B3*2+1",""],
          [4,2,"=C3*3-2",""],
          [4,3,"=B4*2+1",""],
          [5,2,"=C4*3-2",""],
          [5,3,"=B5*2+1",""],
          [6,2,"=C5*3-2",""],
          [6,3,"=B6*2+1",""],
          [7,2,"=C6*3-2",""],
          [7,3,"=B7*2+1",""],
          [8,2,"=SUM(Countries!DATA)  / C7",""],
          [8,3,"<- uses math from this and from Countries sheet","wss2"],
          [8,4,"","wss2"],
          [8,5,"","wss2"],
          [8,6,"","wss2"]
        ]
      }
    },
    {
      "name":"Countries",
      "content":{
        "styles":[
          ["wss1",";;right;;;;;;;;;;;;;"],
          ["wss2",";#4a86e8;;;;;;;;;;;;;;"],
          ["wss3","#ffffff;#4a86e8;;;;;;;;;;;;;;"]
        ],
        "ranges":[
          ["DATA","B2:B7"],
          ["NAMES","A2:A7"]
        ],
        "data":[
          [1,1,"Name","wss3"],
          [1,2,"Population","wss3"],
          [2,1,"Belarus",""],
          [2,2,"9","wss1"],
          [3,1,"Russia",""],
          [3,2,"146","wss1"],
          [4,1,"USA",""],
          [4,2,"324","wss1"],
          [5,1,"Germany",""],
          [5,2,"82","wss1"],
          [6,1,"China",""],
          [6,2,"1381","wss1"],
          [7,1,"India",""],
          [7,2,"1311","wss1"]
        ]
      }
    }
  ];
</script>

Would you like to use a spreadsheet with advanced Excel-like features?