I am able to read and process *.xlsx files using an input element of type file and the library exceljs. Also see example code below.
Unfortunately, exceljs does not seem to support open document spreadsheet files *.ods. (The worksheet
is undefined).
=> How can I read and process *.ods files with javascript?
https://github.com/exceljs/exceljs
https://github.com/exceljs/exceljs/issues/716
static async readFile(file){
await this.__initializeExcel();
const workbook = new Excel.Workbook();
await workbook.xlsx.load(file);
const worksheet = workbook.worksheets[0];
var data = [];
const numberOfRows = worksheet.rowCount;
for (let rowIndex = 1; rowIndex <= numberOfRows; rowIndex++) {
const row = worksheet.getRow(rowIndex);
const rowValues = row.values;
data.push(rowValues);
rowValues.shift();
}
return data;
}
Related