workign excel import

This commit is contained in:
Jan Prochazka
2020-06-18 15:08:58 +02:00
parent 967c5860c9
commit 8425fc46a7
6 changed files with 196 additions and 20 deletions

View File

@@ -0,0 +1,19 @@
const exceljs = require('exceljs');
const _ = require('lodash');
module.exports = {
openedReaders: {},
analyseExcel_meta: 'get',
async analyseExcel({ filePath }) {
const workbook = new exceljs.Workbook();
await workbook.xlsx.readFile(filePath);
return {
tables: workbook.worksheets.map((sheet) => {
const header = sheet.getRow(1);
const columns = _.range(header.cellCount).map((index) => ({ columnName: header.getCell(index + 1).value }));
return { pureName: sheet.name, columns };
}),
};
},
};