mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
⚡ Make it possible to specifically read spreadsheets as string #388
This commit is contained in:
parent
3b074ef87d
commit
45ee6472de
|
@ -196,6 +196,20 @@ export class SpreadsheetFile implements INodeType {
|
|||
default: false,
|
||||
description: 'If the data should be returned RAW instead of parsed.',
|
||||
},
|
||||
{
|
||||
displayName: 'Read As String',
|
||||
name: 'readAsString',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/operation': [
|
||||
'fromFile'
|
||||
],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'In some cases and file formats, it is necessary to read<br />specifically as string else some special character get interpreted wrong.',
|
||||
},
|
||||
{
|
||||
displayName: 'Sheet Name',
|
||||
name: 'sheetName',
|
||||
|
@ -259,7 +273,12 @@ export class SpreadsheetFile implements INodeType {
|
|||
|
||||
// Read the binary spreadsheet data
|
||||
const binaryData = Buffer.from(item.binary[binaryPropertyName].data, BINARY_ENCODING);
|
||||
const workbook = xlsxRead(binaryData, { raw: options.rawData as boolean });
|
||||
let workbook;
|
||||
if (options.readAsString === true) {
|
||||
workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean });
|
||||
} else {
|
||||
workbook = xlsxRead(binaryData, { raw: options.rawData as boolean });
|
||||
}
|
||||
|
||||
if (workbook.SheetNames.length === 0) {
|
||||
throw new Error('Spreadsheet does not have any sheets!');
|
||||
|
|
Loading…
Reference in a new issue