mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 11:16:01 +00:00
20 lines
557 B
JavaScript
20 lines
557 B
JavaScript
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 };
|
|
}),
|
|
};
|
|
},
|
|
};
|