建立試算表
本頁說明如何建立試算表。
範例
如要建立試算表,請在 spreadsheets 集合上使用 create 方法,如以下範例所示。
這個範例會建立空白試算表,並指定標題。
使用 Google 雲端硬碟資料夾
您無法使用 Sheets API 直接在指定的 Google 雲端硬碟資料夾中建立試算表。根據預設,系統會將建立的試算表儲存到使用者在雲端硬碟中的根資料夾。
不過,有 2 種方法可以將檔案儲存到雲端硬碟資料夾:
無論選擇哪種方法,都必須新增適當的 Drive API 範圍,才能授權呼叫。
如要移動或建立共用雲端硬碟資料夾中的檔案,請參閱「實作共用雲端硬碟支援功能」。
如要進一步瞭解 Google 試算表的儲存格和列限制,請參閱「Google 雲端硬碟可存放的檔案」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-12-21 (世界標準時間)。
[null,null,["上次更新時間:2024-12-21 (世界標準時間)。"],[[["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"]]