SpreadJS Documentation
Setting Large Amounts of Data
SpreadJS Documentation > Developer's Guide > Best Practices > Setting Large Amounts of Data

You can insert large amounts of data using the setArray method instead of the setValue method in order to achieve optimized performance. The setArray method sets the values in the specified two-dimensional array of objects into the specific range of cells of the worksheet.

When you're dealing with spreadsheets having bulk data, using the setArray method improves the overall performance of the spreadsheet (as compared to the setValue method), both in terms of memory footprint and efficiency.  

Refer to the following code snippet in order to set large amounts of data using the setArray method.

JavaScript
Copy Code

var spread = new GC.Spread.Sheets.Workbook(document.getElementById('ss'), { sheetCount: 1 });
var sheet = spread.getSheet(0);

// Setting array of values
var dataArray = [
["", 'Chrome', 'Firefox', 'IE', 'Safari', 'Edge', 'Opera', 'Other'],
["2017", 0.6360, 0.1304, 0.0834, 0.0589, 0.0443, 0.0223, 0.0246],
["2018", 0.3260, 0.2638, 0.1828, 0.0367, 0.9721, 0.2732, 0.3762],

];
sheet.setArray(0, 0, dataArray, false);

// Setting array of formulas
var formulaArray = [["=1+1", "=2+2", "=3+3"], ["=4+4", "=5+5", "=6+6"], ["=7+7", "=8+8", "=9+9"]];
sheet.setArray(5, 2, formulaArray, true);