Writes a 2D array of values into a range of cells.
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
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.
Snippets using this method
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.
More Apps Script
Better Sheets tutorials
Build a Case Converter From Scratch
Create a Radio Button From Checkboxes Using Google Apps Script
Google Maps Scraper for Outreach
How To Format Sheets for Notes
Related blog posts
Written guides about SpreadsheetApp.setValues().
How to reference a different Google Spreadsheet in Apps Script?
Transferring Data Between Cells in Different Spreadsheets
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →Explore Coding in Google Sheets
Did you know you can actually code in Google Sheets?
Read post →