Background:
To have extra columns or rows in your SpreadJS instances after importing an xlsx file, we must use the setColumnCount and setRowCount methods after the file is imported using fromJson method.
Steps to Complete:
1. Create a new function called addColRow
2. Set the addColRow function after the fromJson method
Getting Started:
Create a new function called addColRow:
To set the column and row count, use the setColumnCount and setRowCount method.
Below is setting the row and column count to both be 20.
function addColRow(sheet){
var sheet = spread.getActiveSheet();
sheet.setColumnCount(20, GC.Spread.Sheets.SheetArea.viewport);
sheet.setRowCount(20, GC.Spread.Sheets.SheetArea.viewport);
}
Set the addColRow function after the fromJson method:
// here is excel IO API
excelIo.open(excelFile, function (json) {
var workbookObj = json;
spread.fromJSON(workbookObj);
addColRow();
}, function (e) {
// process error
alert(e.errorMessage);
if (e.errorCode === 2/*noPassword*/ || e.errorCode === 3 /*invalidPassword*/) {
document.getElementById('password').onselect = null;
}
}, {password: password});
Note: You can test this here using our Excel IO demo: SpreadJS –Features –Excel Import Export –Excel IO
Tags:
Mackenzie Albitz