fix(Google Sheets Node): Fix exception if no matching rows are found

This commit is contained in:
Michael Kret 2022-11-29 13:29:47 +02:00 committed by GitHub
parent aff8cd9a2b
commit 579f9c4d4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -129,6 +129,7 @@ export function trimLeadingEmptyRows(
}
export function removeEmptyColumns(data: SheetRangeData) {
if (!data || data.length === 0) return [];
const returnData: SheetRangeData = [];
const longestRow = data.reduce((a, b) => (a.length > b.length ? a : b), []).length;
for (let col = 0; col < longestRow; col++) {
@ -138,7 +139,7 @@ export function removeEmptyColumns(data: SheetRangeData) {
returnData.push(column);
}
}
return returnData[0].map((_, i) => returnData.map((row) => row[i] || ''));
return (returnData[0] || []).map((_, i) => returnData.map((row) => row[i] || ''));
}
export function prepareSheetData(