feat(Google Sheets Node): Add "By Name" option to selector for Sheets (#8241)

Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
Elias Meire
2024-01-10 14:30:09 +01:00
committed by GitHub
parent e796e7f06d
commit dce28f9cb9
8 changed files with 87 additions and 46 deletions

View File

@@ -20,15 +20,16 @@ export async function getMappingColumns(
const spreadsheetId = getSpreadsheetId(this.getNode(), mode as ResourceLocator, value as string);
const sheet = new GoogleSheet(spreadsheetId, this);
let sheetWithinDocument = this.getNodeParameter('sheetName', undefined, {
const sheetWithinDocument = this.getNodeParameter('sheetName', undefined, {
extractValue: true,
}) as string;
const { mode: sheetMode } = this.getNodeParameter('sheetName', 0) as { mode: ResourceLocator };
if (sheetWithinDocument === 'gid=0') {
sheetWithinDocument = '0';
}
const sheetName = await sheet.spreadsheetGetSheetNameById(this.getNode(), sheetWithinDocument);
const { title: sheetName } = await sheet.spreadsheetGetSheet(
this.getNode(),
sheetMode,
sheetWithinDocument,
);
const sheetData = await sheet.getData(`${sheetName}!1:1`, 'FORMATTED_VALUE');
const columns = sheet.testFilter(sheetData || [], 0, 0).filter((col) => col !== '');