Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Sheets API appendValues does not use newAppendCellsRequest() and range parameter need clarification.

オープン
#522 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

@jpoehnelt がすでに取り組んでいます。

2025年2月14日 から。

評価

この issue はまだ評価されていません。

説明

The Google Apps Script snippet for Sheets API Snippets.prototype.appendValues() does not use the provided Sheets.newAppendCellsRequest() sheetId and rows properties.
See

Further, the parameter range JSdoc definition is unclear. It is recommended that the definition be copied from the documentation:

The A1 notation of a range to search for a logical table of data

See docs

There are a number of issues with the Sheets.newAppendCellsRequest() that I have raised in the issue tracker here.

Two possible solutions

Both include updated JSDoc descriptions

1. Includes newAppendCellsRequest() correctly in request.
/**
 * Appends values to the specified range
 * @param {string} spreadsheetId spreadsheet's ID
 * @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 {*[][]} _values list of rows of values to input
 * @returns {*} spreadsheet with appended values
 */
Snippets.prototype.appendValues = (spreadsheetId, range,
  valueInputOption, _values) => {
  let values = [
    [
      // Cell values ...
    ]
    // Additional rows ...
  ];
  // [START_EXCLUDE silent]
  values = _values;
  // [END_EXCLUDE]
  try {
    let valueRange = Sheets.newRowData();
    valueRange.values = values;

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

    const result = Sheets.Spreadsheets.Values.append(
      appendRequest.rows, 
      appendRequest.sheetId, 
      range, 
      { valueInputOption: valueInputOption }
    );
    return result;
  } catch (err) {
    // TODO (developer) - Handle exception
    console.log('Failed with error %s', err.message);
  }
};
2. Without newAppendCellsRequest()
/**
 * Appends values to the specified range
 * @param {string} spreadsheetId spreadsheet's ID
 * @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 {*[][]} _values list of rows of values to input
 * @returns {*} spreadsheet with appended values
 */
Snippets.prototype.appendValues = (spreadsheetId, range,
  valueInputOption, _values) => {
  let values = [
    [
      // Cell values ...
    ]
    // Additional rows ...
  ];
  // [START_EXCLUDE silent]
  values = _values;
  // [END_EXCLUDE]
  try {
    let valueRange = Sheets.newRowData();
    valueRange.values = values;

    const result = Sheets.Spreadsheets.Values.append(valueRange, spreadsheetId,
      range, {valueInputOption: valueInputOption});
    return result;
  } catch (err) {
    // TODO (developer) - Handle exception
    console.log('Failed with error %s', err.message);
  }
};
主要言語
JavaScript
スター
5.2k
フォーク
2k
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleworkspace/apps-script-samples のほかの issue

googleworkspace/apps-script-samples の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。