Posted 9 June 2021, 6:30 pm EST
How can I open my folder in a browser to see a list of my xlsx files, and then when I click on any file, it will open through SpreadJS?
Forums Home / Spread / SpreadJS
Posted by: omen1288 on 9 June 2021, 6:30 pm EST
Posted 9 June 2021, 6:30 pm EST
How can I open my folder in a browser to see a list of my xlsx files, and then when I click on any file, it will open through SpreadJS?
Posted 10 June 2021, 7:47 pm EST
Hi,
SpreadJS supports the ExcelIO module by which you could import/export excel files. Please refer to the following demo which demonstrates the same.
How can I open my folder in a browser to see a list of my xlsx files,
You need to use the input element with file type by which you could select any file from the system.
excel Import Export Demo:
https://www.grapecity.com/spreadjs/demos/features/workbook/excel-import-export/purejs
Regards
Avinash
Posted 13 June 2021, 4:51 pm EST
HI,
For this, you need to get the file path and read the file as a blob. Please refer to the following code snippet and attached sample that demonstrates the same.
function importWorkBook(file) {
// here is excel IO API
excelIO.open(
file,
function (json) {
var workbookObj = json;
console.log(JSON.stringify(json));
spread.fromJSON(workbookObj, {
doNotRecalculateAfterLoad: true
});
},
function (e) {
// process error
alert(e.errorMessage);
}
);
}
document.getElementById("load").addEventListener("click", () => {
let path = "../resources/template.xlsx";
fetch(path)
.then((res) => {
return res.blob();
})
.then((res) => {
importWorkBook(res);
});
});
sample: https://codesandbox.io/s/spread-js-starter-forked-gyqpp?file=/src/index.js
Regards
Avinash