Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update spreadsheet_snippets.gs to include Sheets.newAppendCellsRequest() & update the range param definition #523

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sheets/api/spreadsheet_snippets.gs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ Snippets.prototype.batchUpdateValues =
/**
* Appends values to the specified range
* @param {string} spreadsheetId spreadsheet's ID
* @param {string} range range of cells in the spreadsheet
* @param {string} range The A1 notation of a range to search for a logical table of data.
* @param valueInputOption determines how the input should be interpreted
* @see
* https://developers.google.com/sheets/api/reference/rest/v4/ValueInputOption
* @param {list<string>} _values list of rows of values to input
* @param {*[][]} _values list of rows of values to input
* @returns {*} spreadsheet with appended values
*/
Snippets.prototype.appendValues = (spreadsheetId, range,
Expand All @@ -255,10 +255,14 @@ Snippets.prototype.appendValues = (spreadsheetId, range,

let appendRequest = Sheets.newAppendCellsRequest();
appendRequest.sheetId = spreadsheetId;
appendRequest.rows = [valueRange];

const result = Sheets.Spreadsheets.Values.append(valueRange, spreadsheetId,
range, {valueInputOption: valueInputOption});
appendRequest.rows = valueRange;

const result = Sheets.Spreadsheets.Values.append(
appendRequest.rows,
appendRequest.sheetId,
range,
{ valueInputOption: valueInputOption }
);
return result;
} catch (err) {
// TODO (developer) - Handle exception
Expand Down