mirror of
https://github.com/dbgate/dbgate
synced 2024-11-08 04:35:58 +00:00
single file options in excel export
This commit is contained in:
parent
7ccb1d9c90
commit
03451c6897
@ -21,6 +21,32 @@ const excelFormat: FileFormatDefinition = {
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
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;
|
||||
|
@ -14,4 +14,6 @@ export interface FileFormatDefinition {
|
||||
[key: string]: any;
|
||||
}
|
||||
) => void;
|
||||
getDefaultOutputName?: (sourceName, values) => string;
|
||||
getOutputParams?: (sourceName, values) => any;
|
||||
}
|
||||
|
@ -10,7 +10,11 @@ export function getTargetName(source, values) {
|
||||
const key = `targetName_${source}`;
|
||||
if (values[key]) return values[key];
|
||||
const format = findFileFormat(values.targetStorageType);
|
||||
if (format) return `${source}.${format.extension}`;
|
||||
if (format) {
|
||||
const res = format.getDefaultOutputName ? format.getDefaultOutputName(source, values) : null;
|
||||
if (res) return res;
|
||||
return `${source}.${format.extension}`;
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
@ -113,10 +117,15 @@ function getTargetExpr(sourceName, values, targetConnection, targetDriver) {
|
||||
const { targetStorageType } = values;
|
||||
const format = findFileFormat(targetStorageType);
|
||||
if (format && format.writerFunc) {
|
||||
const outputParams = format.getOutputParams && format.getOutputParams(sourceName, values);
|
||||
return [
|
||||
format.writerFunc,
|
||||
{
|
||||
...(outputParams
|
||||
? outputParams
|
||||
: {
|
||||
fileName: getTargetName(sourceName, values),
|
||||
}),
|
||||
...extractApiParameters(values, 'target', format),
|
||||
},
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user