Import Array of JSON Data into spread JS

641 views Asked by At

I am trying to import an array of object into spreadjs, I am using the fromJSON method but it doesnt get imported, my data is an array of object that looks like this

let jsonObj = 
 [{ 'name' : 'One',
   'id': 1,
   'colour': 'blue'
 },
 { 'name' : 'Two',
   'id': 2,
   'colour': 'yellow'
 },
 { 'name' : 'Three',
   'id': 3,
   'colour': 'red'
 }]

I am currently doing sheet.fromJSON(jsonObj)

1

There are 1 answers

0
MESCIUS Team On

Thank for using GrapeCity SpreadJS - fromJSON method is used to load a complete spreadsheet file based on our SSJSON file format. However, to load an array you can use setBindingPath and setDataSource methods to bind cells to your object properties and then bind the array.

here is an example