mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 09:04:07 -08:00
5e16dd4ab4
Github issue / Community forum post (link here to close automatically): --------- Co-authored-by: Giulio Andreini <andreini@netseven.it> Co-authored-by: Marcus <marcus@n8n.io>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
|
|
|
import * as fromFile from '../../../SpreadsheetFile/v2/fromFile.operation';
|
|
|
|
export const operations = ['csv', 'html', 'rtf', 'ods', 'xls', 'xlsx'];
|
|
|
|
export const description: INodeProperties[] = fromFile.description
|
|
.filter((property) => property.name !== 'fileFormat')
|
|
.map((property) => {
|
|
const newProperty = { ...property };
|
|
newProperty.displayOptions = {
|
|
show: {
|
|
operation: operations,
|
|
},
|
|
};
|
|
|
|
if (newProperty.name === 'options') {
|
|
newProperty.options = (newProperty.options as INodeProperties[]).map((option) => {
|
|
let newOption = option;
|
|
if (['delimiter', 'fromLine', 'maxRowCount', 'enableBOM'].includes(option.name)) {
|
|
newOption = { ...option, displayOptions: { show: { '/operation': ['csv'] } } };
|
|
}
|
|
if (option.name === 'sheetName') {
|
|
newOption = {
|
|
...option,
|
|
displayOptions: { show: { '/operation': ['ods', 'xls', 'xlsx'] } },
|
|
description: 'Name of the sheet to read from in the spreadsheet',
|
|
};
|
|
}
|
|
if (option.name === 'range') {
|
|
newOption = {
|
|
...option,
|
|
displayOptions: { show: { '/operation': ['ods', 'xls', 'xlsx'] } },
|
|
};
|
|
}
|
|
if (['includeEmptyCells', 'headerRow'].includes(option.name)) {
|
|
newOption = {
|
|
...option,
|
|
displayOptions: { show: { '/operation': ['ods', 'xls', 'xlsx', 'csv', 'html'] } },
|
|
};
|
|
}
|
|
return newOption;
|
|
});
|
|
}
|
|
return newProperty;
|
|
});
|
|
|
|
export async function execute(
|
|
this: IExecuteFunctions,
|
|
items: INodeExecutionData[],
|
|
fileFormatProperty: string,
|
|
) {
|
|
const returnData: INodeExecutionData[] = await fromFile.execute.call(
|
|
this,
|
|
items,
|
|
fileFormatProperty,
|
|
);
|
|
return returnData;
|
|
}
|