Get Data from a Sheet


There are a few different ways to get all of the data from a specific sheet. The fastest way is to use the .getDataRange() method. The only issue with this method is that it'll literally grab everything from the sheet even if there's a random value somewhere outside of the main data area.

To be more precise with the range you grab data from, you can use the .getRange() method which accepts both A1 Notation as well as numerical parameters.

For A1 Notation, you can do this:

// sheet.getRange("A1 Notation Range") sheet.getRange("A1:J616")



For numerical parameters, you'll do something like this:

sheet.getRange(1, 1, 616, 10)

For the numerical parameters, you must specific the starting row, the starting column, and also how many rows and columns to grab. To put it in an example:

sheet.getRange( startingRow, startingColumn, numberRows, numberColumns )

I personally find the numerical parameters more accurate since it works nicely with other data sets when you're trying to import data from another place. In those cases, you only have the data length counts which means you would have to use the numerical approach to reference the correct data grid to insert the data into.

thumbnail

NitroGAS Chrome Extension

Want to reference this code snippet right from your Google Apps Script Project? Check out our NitroGAS Chrome Extension. This tool will help you build your scripts faster than you could imagine. The tool itself and access to the code snippets are 100% FREE - Happy Coding!

Get the Extension