Skip to content

Commit

Permalink
feat(SpreadsheetFile Node): Allow skipping headers when writing sprea…
Browse files Browse the repository at this point in the history
…dsheets (#3234)

* ⚡ Allow skipping headers when writing spreadsheets

* Fix type on sheet options
  • Loading branch information
drudge authored Jul 10, 2022
1 parent 6b2db8e commit dbfb8d5
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from 'n8n-workflow';

import {
JSON2SheetOpts,
read as xlsxRead,
Sheet2JSONOpts,
utils as xlsxUtils,
Expand Down Expand Up @@ -216,6 +217,7 @@ export class SpreadsheetFile implements INodeType {
show: {
'/operation': [
'fromFile',
'toFile',
],
},
},
Expand Down Expand Up @@ -437,7 +439,10 @@ export class SpreadsheetFile implements INodeType {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
const fileFormat = this.getNodeParameter('fileFormat', 0) as string;
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
let item: INodeExecutionData;
const itemData: IDataObject[] = [];
Expand All @@ -446,7 +451,7 @@ export class SpreadsheetFile implements INodeType {
itemData.push(flattenObject(item.json));
}

const ws = xlsxUtils.json_to_sheet(itemData);
const ws = xlsxUtils.json_to_sheet(itemData, sheetToJsonOptions);

const wopts: WritingOptions = {
bookSST: false,
Expand Down

0 comments on commit dbfb8d5

Please sign in to comment.