mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 07:36:01 +00:00
53 lines
1.2 KiB
TypeScript
53 lines
1.2 KiB
TypeScript
import axios from '../utility/axios';
|
|
import fileFormatBase from './fileFormatBase';
|
|
import { FileFormatDefinition } from './types';
|
|
|
|
const excelFormat: FileFormatDefinition = {
|
|
...fileFormatBase,
|
|
storageType: 'excel',
|
|
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 sheetNames = resp.data;
|
|
for (const sheetName of sheetNames) {
|
|
newSources.push(sheetName);
|
|
newValues[`sourceFile_${sheetName}`] = {
|
|
fileName: file.full,
|
|
sheetName,
|
|
};
|
|
}
|
|
},
|
|
|
|
args: [
|
|
{
|
|
type: 'checkbox',
|
|
name: 'singleFile',
|
|
label: 'Create single file',
|
|
direction: 'target',
|
|
},
|
|
],
|
|
|
|
getDefaultOutputName: (sourceName, values) => {
|
|
if (values.target_excel_singleFile) {
|
|
return sourceName;
|
|
}
|
|
return null;
|
|
},
|
|
|
|
getOutputParams: (sourceName, values) => {
|
|
if (values.target_excel_singleFile) {
|
|
return {
|
|
sheetName: values[`targetName_${sourceName}`] || sourceName,
|
|
fileName:'data.xlsx'
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
};
|
|
|
|
export default excelFormat;
|