mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
feat(SpreadsheetFile Node): Allow skipping headers when writing spreadsheets (#3234)
* ⚡ Allow skipping headers when writing spreadsheets
* Fix type on sheet options
This commit is contained in:
parent
6b2db8e4f4
commit
dbfb8d56dc
|
@ -9,6 +9,7 @@ import {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
JSON2SheetOpts,
|
||||||
read as xlsxRead,
|
read as xlsxRead,
|
||||||
Sheet2JSONOpts,
|
Sheet2JSONOpts,
|
||||||
utils as xlsxUtils,
|
utils as xlsxUtils,
|
||||||
|
@ -216,6 +217,7 @@ export class SpreadsheetFile implements INodeType {
|
||||||
show: {
|
show: {
|
||||||
'/operation': [
|
'/operation': [
|
||||||
'fromFile',
|
'fromFile',
|
||||||
|
'toFile',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -437,7 +439,10 @@ export class SpreadsheetFile implements INodeType {
|
||||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
|
||||||
const fileFormat = this.getNodeParameter('fileFormat', 0) as string;
|
const fileFormat = this.getNodeParameter('fileFormat', 0) as string;
|
||||||
const options = this.getNodeParameter('options', 0, {}) as IDataObject;
|
const options = this.getNodeParameter('options', 0, {}) as IDataObject;
|
||||||
|
const sheetToJsonOptions: JSON2SheetOpts = {};
|
||||||
|
if (options.headerRow === false) {
|
||||||
|
sheetToJsonOptions.skipHeader = true;
|
||||||
|
}
|
||||||
// Get the json data of the items and flatten it
|
// Get the json data of the items and flatten it
|
||||||
let item: INodeExecutionData;
|
let item: INodeExecutionData;
|
||||||
const itemData: IDataObject[] = [];
|
const itemData: IDataObject[] = [];
|
||||||
|
@ -446,7 +451,7 @@ export class SpreadsheetFile implements INodeType {
|
||||||
itemData.push(flattenObject(item.json));
|
itemData.push(flattenObject(item.json));
|
||||||
}
|
}
|
||||||
|
|
||||||
const ws = xlsxUtils.json_to_sheet(itemData);
|
const ws = xlsxUtils.json_to_sheet(itemData, sheetToJsonOptions);
|
||||||
|
|
||||||
const wopts: WritingOptions = {
|
const wopts: WritingOptions = {
|
||||||
bookSST: false,
|
bookSST: false,
|
||||||
|
|
Loading…
Reference in a new issue