Skip to main content

gsheets.googlesheets.getvalues

Home > @runlightyear/gsheets > GoogleSheets > getValues

GoogleSheets.getValues() method

This API is in beta and may contain contain bugs. Can be used in production with caution.

Returns a range of values from a spreadsheet.

Signature:
getValues(props: GetValuesProps): Promise<GetValuesResponse>;

Parameters

ParameterTypeDescription
propsGetValuesProps
Returns:

Promise<GetValuesResponse>

Example 1

Get a row

import { defineAction } from "@runlightyear/lightyear";
import { GoogleSheets } from "@runlightyear/gsheets";

defineAction({
name: "getRow",
title: "Get Row",
apps: ["gsheets"],
variables: ["spreadsheetId"],
run: async ({ auths, variables }) => {
const gsheets = new GoogleSheets({
auth: auths.gsheets,
});

const response = await gsheets.getValues({
spreadsheetId: variables.spreadsheetId!,
range: "1:1",
});

console.log("Response: ", response.data);
},
});

Example 2

Get a column

import { defineAction } from "@runlightyear/lightyear";
import { GoogleSheets } from "@runlightyear/gsheets";

defineAction({
name: "getColumn",
title: "Get Column",
apps: ["gsheets"],
variables: ["spreadsheetId"],
run: async ({ auths, variables }) => {
const gsheets = new GoogleSheets({
auth: auths.gsheets,
});

const response = await gsheets.getValues({
spreadsheetId: variables.spreadsheetId!,
range: "A:A",
majorDimension: "COLUMNS",
});

console.log("Response: ", response.data);
},
});

Example 3

Get all rows and columns

import { defineAction } from "@runlightyear/lightyear";
import { GoogleSheets } from "@runlightyear/gsheets";

defineAction({
name: "getAllRowsAndColumns",
title: "Get All Rows And Columns",
apps: ["gsheets"],
variables: ["spreadsheetId", "worksheetName"],
run: async ({ auths, variables }) => {
const gsheets = new GoogleSheets({
auth: auths.gsheets,
});

const response = await gsheets.getValues({
spreadsheetId: variables.spreadsheetId!,
range: `${variables.worksheetName!}`,
});

console.log("Response: ", response.data);
},
});