This page describes how to create a spreadsheet.
Example
To create a spreadsheet, use the create method on the spreadsheets collection, as shown in the following example.
This example creates a blank spreadsheet with a specified title.
Apps Script
Java
JavaScript
Node.js
PHP
Python
Ruby
Work with Google Drive folders
There’s no option to create a spreadsheet directly within a specified Drive folder using the Sheets API. By default, the created spreadsheet is saved to the user’s root folder on Drive.
However, there are 2 alternatives to saving a file to a Drive folder:
- After the spreadsheet is created, move it to a specific folder using the files.update method of the Drive API. For more information on moving files, refer to Move files between folders.
- Add a blank spreadsheet to a folder using the files.create method of the Drive API, specifying
application/vnd.google-apps.spreadsheet
as themimeType
. For more information on creating files, refer to Create a file in a folder.
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.