mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(Google Sheets Node): Fix for auto-range detection
This commit is contained in:
parent
acfb3518ad
commit
77031a2950
|
@ -582,6 +582,7 @@ export class GoogleSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over all the lookup values and try to find a row to return
|
// Loop over all the lookup values and try to find a row to return
|
||||||
let rowIndex: number;
|
let rowIndex: number;
|
||||||
let returnColumnIndex: number;
|
let returnColumnIndex: number;
|
||||||
|
@ -617,7 +618,13 @@ export class GoogleSheet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.convertSheetDataArrayToObjectArray(removeEmptyColumns(returnData), 1, keys, true);
|
const dataWithoutEmptyColumns = removeEmptyColumns(returnData);
|
||||||
|
return this.convertSheetDataArrayToObjectArray(
|
||||||
|
dataWithoutEmptyColumns,
|
||||||
|
1,
|
||||||
|
dataWithoutEmptyColumns[0] as string[],
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async convertObjectArrayToSheetDataArray(
|
private async convertObjectArrayToSheetDataArray(
|
||||||
|
|
|
@ -134,6 +134,10 @@ export function removeEmptyColumns(data: SheetRangeData) {
|
||||||
const longestRow = data.reduce((a, b) => (a.length > b.length ? a : b), []).length;
|
const longestRow = data.reduce((a, b) => (a.length > b.length ? a : b), []).length;
|
||||||
for (let col = 0; col < longestRow; col++) {
|
for (let col = 0; col < longestRow; col++) {
|
||||||
const column = data.map((row) => row[col]);
|
const column = data.map((row) => row[col]);
|
||||||
|
if (column[0] !== '') {
|
||||||
|
returnData.push(column);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
const hasData = column.slice(1).some((cell) => cell || typeof cell === 'number');
|
const hasData = column.slice(1).some((cell) => cell || typeof cell === 'number');
|
||||||
if (hasData) {
|
if (hasData) {
|
||||||
returnData.push(column);
|
returnData.push(column);
|
||||||
|
|
Loading…
Reference in a new issue