Create a spreadsheet
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.
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 the mimeType
. 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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-19 UTC.
[null,null,["Last updated 2024-12-19 UTC."],[[["This page provides code samples demonstrating how to create a blank Google Spreadsheet using the Sheets API in various programming languages."],["By default, new spreadsheets are created in the user's root Drive folder, requiring the Drive API to move them to a specific folder."],["You can alternatively create a blank spreadsheet directly within a folder using the Drive API, specifying the appropriate MIME type."],["Refer to the linked resources for information on Drive API scopes, shared drive support, and Google Sheets limitations."]]],["To create a spreadsheet, utilize the `spreadsheets.create` method, specifying the desired title within the `properties` field. This action generates a blank spreadsheet. By default, spreadsheets are saved in the user's root folder in Drive. To save to a specific folder, use the Drive API's `files.update` method to move it or `files.create` to directly add it to the folder. The examples given use `Apps Script`, `Java`, `Javascript`, `Node.js`, `PHP`, `Python`, and `Ruby`.\n"]]