This document explains how to create and manage spreadsheets in Google Sheets using the Google Sheets API.
Create a spreadsheet
To create a file in Sheets, use the create
method on the spreadsheets
resource
with no parameters.
When you create the file, the method returns a spreadsheets
resource. The
returned resource contains a spreadsheetId
, properties
, a list of sheets
,
and a spreadsheetUrl
.
The following code sample shows how to create a blank spreadsheet with a specified title.
Apps Script
Java
JavaScript
Node.js
PHP
Python
Ruby
Organize spreadsheets in Google Drive folders
By default, the created spreadsheet is saved to the user's root folder on Drive.
If you want to save a spreadsheet to a specified Google Drive folder, use these methods:
-
After the spreadsheet file is created, move it to a specific folder using the
updatemethod on thefilesresource of Drive API. For more information, see Move files between folders . -
Add a blank spreadsheet to a folder using the
createmethod on thefilesresource of Drive API, specifyingapplication/vnd.google-apps.spreadsheetas themimeType. For more information on creating files, see Create a file in a specific folder . For more information on MIME types, see Google Workspace and Google Drive supported MIME types .
For either alternative, you'll need to add the appropriate Drive API scopes to authorize the call.
To move or create a file within a shared drive folder, refer to Implement shared drive support .
To learn more about cell and row limits in Google Sheets, see Files you can store in Google Drive .
Get a spreadsheet
To get a spreadsheet, use the get
method on the spreadsheets
resource with the spreadsheetId
path parameter.
The method returns the file as an instance of a spreadsheets
resource. By
default, data within the spreadsheet isn't returned. The returned resource
contains the structure and metadata of the spreadsheet, including the
spreadsheet properties (such as title, locale, and time zone) and some detailed
sheet information (such as formatting and protected ranges).
To include data within a spreadsheets
resource, use these two methods:
-
Specify a field mask listing your selected fields by setting the
fieldssystem parameter . -
Set the boolean
includeGridDataquery parameter totrue. If a field mask is set, theincludeGridDataparameter is ignored.
When you're working with large spreadsheets, we recommend that you query for
only the specific spreadsheet fields that you need. The get
method returns all
the data associated with the spreadsheet, so general queries for large
spreadsheets can be slow. For example, to read the number 100 from a cell, spreadsheets.get
returns the cell value plus metadata (such as font name,
size, etc.) resulting in large JSON payloads that are slow to parse. In
comparison, a similar call to values.get
returns only the specific cell value
resulting in a much lighter, faster response.
For more information on the spreadsheets.values
resource, including spreadsheets.values.get
and spreadsheets.values.batchGet
,
see the following documents:
Related topics
Here are a few next steps you might try:
-
To update a spreadsheet, see Update spreadsheets .
-
To work with smart chips, see Smart chips .
-
To work with developer metadata, see Read and write developer metadata .

