using xlsx lib instead of exceljs, export excel files

This commit is contained in:
Jan Prochazka
2020-11-19 10:30:06 +01:00
parent 6324fd1de4
commit da805db44b
9 changed files with 192 additions and 412 deletions

View File

@@ -1,4 +1,3 @@
import { DatabaseInfo } from 'dbgate-types';
import axios from '../utility/axios';
import fileFormatBase from './fileFormatBase';
import { FileFormatDefinition } from './types';
@@ -9,16 +8,16 @@ const excelFormat: FileFormatDefinition = {
extension: 'xlsx',
name: 'MS Excel',
readerFunc: 'excelSheetReader',
writerFunc: 'excelSheetWriter',
addFilesToSourceList: async (file, newSources, newValues) => {
const resp = await axios.get(`files/analyse-excel?filePath=${encodeURIComponent(file.full)}`);
const structure: DatabaseInfo = resp.data;
for (const table of structure.tables) {
const sourceName = table.pureName;
newSources.push(sourceName);
newValues[`sourceFile_${sourceName}`] = {
const sheetNames = resp.data;
for (const sheetName of sheetNames) {
newSources.push(sheetName);
newValues[`sourceFile_${sheetName}`] = {
fileName: file.full,
sheetName: table.pureName,
sheetName,
};
}
},