创建电子表格
本页介绍了如何创建电子表格。
示例
如需创建电子表格,请对 spreadsheets 集合使用 create 方法,如以下示例所示。
此示例会创建一个具有指定标题的空白电子表格。
处理 Google 云端硬盘文件夹
您无法使用 Google 表格 API 直接在指定的云端硬盘文件夹中创建电子表格。默认情况下,系统会将创建的电子表格保存到用户云端硬盘的根文件夹中。
不过,您可以通过以下 2 种方式将文件保存到云端硬盘文件夹:
对于这两种方法,您都需要添加适当的 Drive API 权限范围才能授权调用。
如需在共享云端硬盘文件夹中移动或创建文件,请参阅实现共享云端硬盘支持。
如需详细了解 Google 表格中的单元格和行数限制,请参阅可存储在 Google 云端硬盘中的文件。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-12-21。
[null,null,["最后更新时间 (UTC):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"]]