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.
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
No tagged tutorials yet. Fetch Apps Script from the harvest table and this page fills automatically.
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 →How to Use Google Sheets as a Website Database
Did you know you can use Google Apps Script to turn a Google Sheet into a free, auto-syncing database for your website? This guide shows you exactly how to set it up. You’ll prepare your spreadsheet, write a few lines of code and publish your site. Don’t worry if you’re not a developer, we’ll walk you through it. Why Use Google Sheets as a Database? For small projects, Google Sheets offers many advantages over traditional databases: * Free hosting and storage * Easy to edit data without...
Read post →