class SpreadsheetApp method .setValues()

SpreadsheetApp is the Apps Script service.

.setValues() is the method name you will see after a dot in your code.

What it does

Writes a 2D array of values into a range of cells.

Why it's used

  • Paste a whole calculated table back in one write.
  • Fill a report block from API results or transformed data.

Common errors

  • Forgetting parentheses on setValues. Write SpreadsheetApp.setValues(), not SpreadsheetApp.setValues or setValues by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').setValues().
  • Adding spaces where they do not belong. Write SpreadsheetApp.setValues(), not SpreadsheetApp .setValues(), SpreadsheetApp.setValues (), or SpreadsheetApp . setValues().
  • Wrong capitalization. Use SpreadsheetApp and setValues, not spreadsheetapp or setvalues.

Explore

Related methods

  • .getValues()

    Reads values from every cell in a range as a 2D array.

  • .setValue()

    Writes a value into a single cell.

  • .offset()

    Returns a range shifted by a number of rows and columns.

  • .getValue()

    Reads the value stored in a single cell.

  • .getRange()

    Returns a range of cells by A1 notation or row and column numbers.

Better Sheets tutorials

No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.

Related blog posts

Written guides about SpreadsheetApp.setValues().

Browse the blog