mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 18:43:58 +00:00
excel import - ability to skip header
This commit is contained in:
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
{#if arg.type == 'text'}
|
{#if arg.type == 'text'}
|
||||||
<FormTextField label={arg.label} {name} defaultValue={arg.default} />
|
<FormTextField label={arg.label} {name} defaultValue={arg.default} />
|
||||||
|
{:else if arg.type == 'number'}
|
||||||
|
<FormTextField label={arg.label} type="number" {name} defaultValue={arg.default} />
|
||||||
{:else if arg.type == 'checkbox'}
|
{:else if arg.type == 'checkbox'}
|
||||||
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
|
<FormCheckboxField label={arg.label} {name} defaultValue={arg.default} />
|
||||||
{:else if arg.type == 'select'}
|
{:else if arg.type == 'select'}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ async function waitForDrain(stream) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function reader({ fileName, sheetName, limitRows = undefined }) {
|
async function reader({ fileName, sheetName, skipHeaderRows, limitRows = undefined }) {
|
||||||
const pass = new stream.PassThrough({
|
const pass = new stream.PassThrough({
|
||||||
objectMode: true,
|
objectMode: true,
|
||||||
highWaterMark: 100,
|
highWaterMark: 100,
|
||||||
@@ -32,10 +32,18 @@ async function reader({ fileName, sheetName, limitRows = undefined }) {
|
|||||||
const workbook = await loadWorkbook(fileName);
|
const workbook = await loadWorkbook(fileName);
|
||||||
const sheet = workbook.Sheets[sheetName];
|
const sheet = workbook.Sheets[sheetName];
|
||||||
|
|
||||||
|
let range = undefined;
|
||||||
|
if (parseInt(skipHeaderRows) > 0) {
|
||||||
|
range = xlsx.utils.decode_range(sheet['!ref']);
|
||||||
|
range.s.r = parseInt(skipHeaderRows);
|
||||||
|
}
|
||||||
|
|
||||||
const rows = xlsx.utils.sheet_to_json(sheet, {
|
const rows = xlsx.utils.sheet_to_json(sheet, {
|
||||||
header: 1,
|
header: 1,
|
||||||
|
range,
|
||||||
blankrows: false,
|
blankrows: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const header = rows[0];
|
const header = rows[0];
|
||||||
const structure = {
|
const structure = {
|
||||||
__isStreamHeader: true,
|
__isStreamHeader: true,
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ const fileFormat = {
|
|||||||
label: 'Create single file',
|
label: 'Create single file',
|
||||||
direction: 'target',
|
direction: 'target',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'number',
|
||||||
|
default: '0',
|
||||||
|
name: 'skipHeaderRows',
|
||||||
|
apiName: 'skipHeaderRows',
|
||||||
|
label: 'Skip header rows',
|
||||||
|
direction: 'source',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
getDefaultOutputName: (sourceName, values) => {
|
getDefaultOutputName: (sourceName, values) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user