mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 08:26:01 +00:00
using xlsx lib instead of exceljs, export excel files
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const exceljs = require('exceljs');
|
||||
const xlsx = require('xlsx');
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
@@ -6,14 +6,7 @@ module.exports = {
|
||||
|
||||
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 };
|
||||
}),
|
||||
};
|
||||
const workbook = xlsx.readFile(filePath, { bookSheets: true });
|
||||
return workbook.SheetNames;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@ const dbgateApi = require(process.env.DBGATE_API || "dbgate-api");
|
||||
require=null;
|
||||
async function run() {
|
||||
${script}
|
||||
await dbgateApi.finalizer.run();
|
||||
console.log('Finished job script');
|
||||
}
|
||||
dbgateApi.runScript(run);
|
||||
|
||||
Reference in New Issue
Block a user