Skip to main content

gsheets.googlesheets.appendvalues

Home > @runlightyear/gsheets > GoogleSheets > appendValues

GoogleSheets.appendValues() method

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

Appends values to a spreadsheet.

Signature:
appendValues(props: AppendValuesProps): Promise<AppendValuesResponse>;

Parameters

ParameterTypeDescription
propsAppendValuesProps
Returns:

Promise<AppendValuesResponse>

Example 1

Append a row

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

defineAction({
name: "appendRow",
title: "Append Row",
apps: ["gsheets"],
variables: ["spreadsheetId"],
run: async ({ auths, variables }) => {
const gsheets = new GoogleSheets({
auth: auths.gsheets,
});
const response = await gsheets.appendValues({
spreadsheetId: variables.spreadsheetId!,
range: "1:1",
valueInputOption: "RAW",
valueRange: {
range: "1:1",
values: [[1, 2, 3]],
},
});
console.log("Response: ", response.data);
},
});

Example 2

Append multiple rows

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

defineAction({
name: "appendRows",
title: "Append Multiple Rows",
apps: ["gsheets"],
variables: ["spreadsheetId"],
run: async ({ auths, variables }) => {
const gsheets = new GoogleSheets({
auth: auths.gsheets,
});
const response = await gsheets.appendValues({
spreadsheetId: variables.spreadsheetId!,
range: "1:1",
valueInputOption: "RAW",
valueRange: {
range: "1:1",
values: [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
],
},
});
console.log("Response: ", response.data);
},
});