[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-04。"],[],[],null,["This guide describes how and why to use the Google Sheets API to create tables\nin your spreadsheets.\n\nWhat is a table?\n\nWith tables, you can simplify data creation and reduce the need to repeatedly\nformat, input, and update data by automatically applying format and structure to\nranges of data.\n\nTables have many features, such as headers, footers, column types, filters,\nviews, table references, and table names. See more in the\n[feature announcement](https://workspaceupdates.googleblog.com/2024/05/tables-in-google-sheets.html),\nand [learn about using tables in Sheets](https://support.google.com/docs/answer/14239833?hl).\n\nYou can use tables for tasks such as Project Tracking, Event Planning, and\nInventory management.\n\nAdd a table\n\nTo add a table, use the\n[batchUpdate](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate)\nmethod, supplying an\n[addTable](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#addtablerequest)\nrequest. You use this request to add a table to the spreadsheet.\n\nThe following example creates a table named \"Project Tracker\" at the specified\n`range` with 2 set columns. A percent column in the first column and a dropdown\ncolumn type in the second column. \n\n {\n \"addTable\": {\n \"table\": {\n \"name\": \"Project Tracker\",\n \"tableId\": \"123\",\n \"range\": {\n \"sheetId\": 0,\n \"startColumnIndex\": 0,\n \"endColumnIndex\": 5,\n \"startRowIndex\": 0,\n \"endRowIndex\": 5,\n },\n \"columnProperties\": [\n {\n \"columnIndex\": 0,\n \"columnName\": \"Column 1\",\n \"columnType\": \"PERCENT\"\n },\n {\n \"columnIndex\": 1,\n \"columnName\": \"Column 2\",\n \"columnType\": \"DROPDOWN\",\n \"dataValidationRule\": {\n \"condition\": {\n \"type\": \"ONE_OF_LIST\",\n \"values\": [\n {\n \"userEnteredValue\": \"Not Started\"\n },\n {\n \"userEnteredValue\": \"In Progress\"\n },\n {\n \"userEnteredValue\": \"Complete\"\n }\n ]\n }\n }\n }\n ],\n }\n }\n }\n\nColumn types\n\nTables have [column types](https://support.google.com/docs/answer/14239833?hl#zippy=%2Ccreate-table-names%2Cset-column-types)\nsuch as numeric, date, dropdown, smart chip, checkbox. The rating and\ncheckbox column types populate with default values of 0 and FALSE\nrespectively.\n\nDropdown column type\n\nThe dropdown column type creates a chip dropdown. If a column type is set as\ndropdown, the `dataValidationRule` for the column must be set with a\nONE_OF_LIST condition. Other column types shouldn't set the \\`dataValidationRule\nfield.\n\nUpdate a table\n\nUse the [`spreadsheets.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate)\nmethod and supply an [UpdateTableRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#updatetablerequest).\n\nModify the table size\n\nUse the [UpdateTableRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#updatetablerequest)\nmethod to modify the `range` that the table has to add new rows/columns.\n\nIf you need to add a new row or column within the table, use the\n[InsertRangeRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#insertrangerequest)\nor the\n[InsertDimensionRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#insertdimensionrequest)\n\nIf you need to delete a table row you can use [DeleteRangeRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#deleterangerequest)\notherwise you can use [DeleteDimensionRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#deletedimensionrequest)\nto delete an entire row from the spreadsheet.\n| **Note:** If using InsertRangeRequest/DeleteRangeRequest, the range in the request must cover the entire row(s) if deleting a row or entire column(s) if deleting a column.\n\nToggle the table footer\n\nIf you're updating an existing table without a footer to add a footer, the\n`range` expands by 1 row. If you're updating an existing table with a footer\nand removing the footer, the `range` shrinks by 1 row.\n\nAppend values to a table\n\nUse [AppendCellsRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#appendcellsrequest)\nwith `tableId` to add rows to the end of a table. This appends the values to\nthe first free row and is aware of full rows and footers. If there are no\nempty rows, this inserts rows to the end of the table and before any footer,\nif applicable.\n\nDelete a table\n\nUse the [`spreadsheets.batchUpdate`](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate)\nmethod and supply a\n[DeleteTableRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#deletetablerequest).\nUse the [DeleteTableRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#deletetablerequest)\nto delete the entire table and the contents of the table.\n\nUse the [DeleteBandingRequest](/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate#deletebandingrequest)\nto remove the table formatting but keep the data.\n\nUse tables with other Sheets features\n\nOther API features that support tables being their backing data include\n[filters](/workspace/sheets/api/guides/filters#basic-filter),\n[filter views](/workspace/sheets/api/guides/filters#filter-views), and\n[protected ranges](/workspace/sheets/api/reference/rest/v4/spreadsheets/sheets#protectedrange)."]]