Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚡ Allow skipping headers when writing spreadsheets #3234

Merged
merged 3 commits into from
Jul 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -416,7 +418,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 @@ -425,7 +430,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