Posted 6 February 2023, 8:30 am EST
Hello everyone,
I recently upgraded from version 14.2.0 to version 16.0.2. This has added new options to the file open menu.
→ Lazy Load
→ Include unused styles
→ Calculate on demand
→ Dynamic References
Since I overwrote the Open method with my own to have more access to the selected file, I ended up using a call with its fromJSON method. I noticed that the new options do not appear in the deserializationOptions.
Now I am wondering how to implement them.
My overwritten method for excel files:
GC.Spread.Sheets.Designer.FileMenuHandler.importExcel_online = function () {
let incrementalLoading = isOptionChecked("Incremental Loading");
let doNotImportStyle = isOptionChecked("Do not import style");
let doNotImportFormula = isOptionChecked("Do not import formula");
let doNotAutoCalculate = isOptionChecked("Do not auto-calculate formulas after importing");
let frozenColumns = isOptionChecked("Import frozen rows as column headers");
let frozenRows = isOptionChecked("Import frozen columns as row headers");
let password = findInputValue("Password");
let input = document.createElement('input');
input.type = 'file';
input.onchange = _ => {
let files = Array.from(input.files);
console.log(files[0].name);
/*import the excel file*/
var excelIo = new GC.Spread.Excel.IO();
excelIo.open(
files[0],
function (json) {
let designer = new GC.Spread.Sheets.Designer.Designer("designer-container");
let spread = designer.getWorkbook();
var workbookObj = json;
if (incrementalLoading) {
spread.fromJSON(workbookObj, {
ignoreStyle: doNotImportStyle,
ignoreFormula: doNotImportFormula,
frozenColumnsAsRowHeaders: frozenRows,
frozenRowsAsColumnHeaders: frozenColumns,
doNotRecalculateAfterLoad: doNotAutoCalculate,
incrementalLoading: {
loading: function (progress, args) {
console.log("current loading sheet", args.sheet && args.sheet.name());
},
loaded: function () {
console.log("Loaded");
}
}
});
} else {
spread.fromJSON(workbookObj, {
ignoreStyle: doNotImportStyle,
ignoreFormula: doNotImportFormula,
frozenColumnsAsRowHeaders: frozenRows,
frozenRowsAsColumnHeaders: frozenColumns,
doNotRecalculateAfterLoad: doNotAutoCalculate,
});
}
designer.setData("FileMenu_show", false);
},
function (e) {
/* process error*/
alert(e.errorMessage);
if (e.errorCode === 2/*noPassword*/ || e.errorCode === 3 /*invalidPassword*/) {
console.log("password error");
}
}, { password: password }
);
}
input.click();
}
Thanks in advance
Best regards
Maik
