GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values:batchGet?
ranges=Sheet1!B:B&ranges=Sheet1!D:D&valueRenderOption=UNFORMATTED_VALUE&majorDimension=COLUMNS
這個方法呼叫的回覆包含一個物件,其中含有試算表 ID 和 ValueRange 物件陣列,對應每個要求的範圍,並依要求順序排列。majorDimension 欄位表示陣列是依資料欄排序的值清單。例如:
GET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values:batchGet?
ranges=Sheet1!A1:D5&ranges=Products!D1:D100&ranges=Sales!E4:F6&valueRenderOption=UNFORMATTED_VALUE&majorDimension=COLUMNS
這個方法呼叫的回覆包含一個物件,其中含有試算表 ID 和 ValueRange 物件陣列,對應每個要求的範圍,並依要求順序排列。majorDimension 欄位表示陣列是依資料欄排序的值清單。例如:
[[["容易理解","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"]],["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Basic reading\n\nThe Google Sheets API allows you to read values from cells, ranges, sets of ranges,\nand entire sheets. The examples on this page illustrate some common read\noperations with the\n[`spreadsheets.values`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values)\nresource. You can also read cell values using the\n[`spreadsheets.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets/get) method, but\nusually\n[`spreadsheets.values.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/get)\nor\n[`spreadsheets.values.batchGet`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet)\nis easier.\n\nThese examples are presented in the form of HTTP requests to be language\nneutral. To learn how to implement reads in different languages using the Google\nAPI client libraries, see [Read \\& write cell\nvalues](/workspace/sheets/api/guides/values#read).\n\nIn these examples, the placeholder \u003cvar translate=\"no\"\u003eSPREADSHEET_ID\u003c/var\u003e indicates where you\nwould provide the [spreadsheet ID](/workspace/sheets/api/guides/concepts#spreadsheet),\nwhich can be discovered from the spreadsheet URL. The ranges to read from are\nspecified using [A1 notation](/workspace/sheets/api/guides/concepts#cell) in the request\nURL. An example range is Sheet1!A1:D5.\n\nSource data\n-----------\n\nFor these examples, assume the spreadsheet being read has the following source\ndata in its first sheet (\"Sheet1\"). The strings in the first row are labels for\nthe individual columns. To view examples of how to read from other sheets in\nyour spreadsheet, see [A1 notation](/workspace/sheets/api/guides/concepts#cell).\n\n|---|--------|--------|---------|-----------|\n| | A | B | C | D |\n| 1 | Item | Cost | Stocked | Ship Date |\n| 2 | Wheel | $20.50 | 4 | 3/1/2016 |\n| 3 | Door | $15 | 2 | 3/15/2016 |\n| 4 | Engine | $100 | 1 | 3/20/2016 |\n| 5 | Totals | $135.5 | 7 | 3/20/2016 |\n\nRead a single range\n-------------------\n\nThe following\n[`spreadsheets.values.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/get)\ncode sample shows how to read the values from the range Sheet1!A1:D5 and returns\nthem in the response. Empty trailing rows and columns are omitted.\n\nThe request protocol is shown here. \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/Sheet1!A1:D5\n```\n\nThe response consists of a\n[`ValueRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#resource:-valuerange)\nobject that describes the range values. The\n[`majorDimension`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) field\nindicates that the arrays are lists of values organized by rows. \n\n```text\n{\n \"range\": \"Sheet1!A1:D5\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\"Item\", \"Cost\", \"Stocked\", \"Ship Date\"],\n [\"Wheel\", \"$20.50\", \"4\", \"3/1/2016\"],\n [\"Door\", \"$15\", \"2\", \"3/15/2016\"],\n [\"Engine\", \"$100\", \"1\", \"30/20/2016\"],\n [\"Totals\", \"$135.5\", \"7\", \"3/20/2016\"]\n ],\n}\n```\n\nRead a single range grouped by column\n-------------------------------------\n\nThe following\n[`spreadsheets.values.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/get)\ncode sample shows how to read the values from the range Sheet1!A1:D3 and returns\nthem in the response, but grouped by column. Empty trailing rows and columns are\nomitted.\n\nThe request protocol is shown here. \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/Sheet1!A1:D3?majorDimension=COLUMNS\n```\n\nThe response consists of a\n[`ValueRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#resource:-valuerange)\nobject that describes the range values. The\n[`majorDimension`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) field\nindicates that the arrays are lists of values organized by columns. \n\n```text\n{\n \"range\": \"Sheet1!A1:D3\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [\"Item\", \"Wheel\", \"Door\"],\n [\"Cost\", \"$20.50\", \"$15\"],\n [\"Stocked\", \"4\", \"2\"],\n [\"Ship Date\", \"3/1/2016\", \"3/15/2016\"]\n ],\n}\n```\n\nRead a single range with rendering options\n------------------------------------------\n\nThe following\n[`spreadsheets.values.get`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/get)\ncode sample shows how to read the values from the range Sheet1!A1:D5 and returns\nthem in the response, but uses rendering options to manage how that information\nis returned. The\n[`ValueRenderOption`](/workspace/sheets/api/reference/rest/v4/ValueRenderOption) setting\nof `FORMULA` indicates that formulas are to be returned instead of the\ncalculated value, and the\n[`DateTimeRenderOption`](/workspace/sheets/api/reference/rest/v4/DateTimeRenderOption)\nsetting of `SERIAL_NUMBER` indicates that dates are to be returned as numbers.\nOther settings are possible as well. Empty trailing rows and columns are\nomitted.\n\nThe request protocol is shown here. \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values/Sheet1!A1:D5?\n valueRenderOption=FORMULA&dateTimeRenderOption=SERIAL_NUMBER\n```\n\nThe response consists of a\n[`ValueRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#resource:-valuerange)\nobject that describes the range values. The\n[`majorDimension`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) field\nindicates that the arrays are lists of values organized by rows. \n\n```text\n{\n \"range\": \"Sheet1!A1:D5\",\n \"majorDimension\": \"ROWS\",\n \"values\": [\n [\"Item\", \"Cost\", \"Stocked\", \"Ship Date\"],\n [\"Wheel\", \"$20.50\", \"4\", \"42430\"],\n [\"Door\", \"$15\", \"2\", \"42444\"],\n [\"Engine\", \"$100\", \"1\", \"42449\"],\n [\"Totals\", \"=SUM(B2:B4)\", \"=SUM(C2:C4)\", \"=MAX(D2:D4)\"]\n ],\n}\n```\n\nRead multiple ranges\n--------------------\n\nThe following\n[`spreadsheets.values.batchGet`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet)\ncode sample shows how to read values from ranges Sheet1!B:B and Sheet1!D:D and\nreturns them in the response. The\n[`ValueRenderOption`](/workspace/sheets/api/reference/rest/v4/ValueRenderOption) setting\nof `UNFORMATTED_VALUE` indicates that values are calculated, but not formatted\nin the response. Empty trailing rows and columns are omitted.\n\nThe request protocol is shown here. \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values:batchGet?\n ranges=Sheet1!B:B&ranges=Sheet1!D:D&valueRenderOption=UNFORMATTED_VALUE&majorDimension=COLUMNS\n```\n\nThe response to this method call consists of an object with the spreadsheet ID\nand an array of\n[`ValueRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#resource:-valuerange)\nobjects corresponding to each requested range, listed in the order they were\nrequested. The\n[`majorDimension`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) field\nindicates that the arrays are lists of values organized by columns. For example: \n\n```scdoc\n{\n \"spreadsheetId\": SPREADSHEET_ID,\n \"valueRanges\": [\n {\n \"range\": \"Sheet1!B1:B1000\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [\"Cost\",20.5,15,100,135.5]\n ]\n },\n {\n \"range\": \"Sheet1!D1:D1000\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [\"Ship Date\",42430,42444,42449,42449]\n ]s\n }\n ]\n}\n```\n\nRead multiple ranges across multiple sheets\n-------------------------------------------\n\nThe following\n[`spreadsheets.values.batchGet`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values/batchGet)\ncode sample shows how to read values from ranges in sheets Sheet1!A1:D5,\nProducts!D1:D100, and Sales!E4:F6 and returns them in the response. The\n[`ValueRenderOption`](/workspace/sheets/api/reference/rest/v4/ValueRenderOption) setting\nof `UNFORMATTED_VALUE` indicates that values are calculated, but not formatted\nin the response. Empty trailing rows and columns are omitted.\n\nThe request protocol is shown here. \n\n```\nGET https://sheets.googleapis.com/v4/spreadsheets/SPREADSHEET_ID/values:batchGet?\n ranges=Sheet1!A1:D5&ranges=Products!D1:D100&ranges=Sales!E4:F6&valueRenderOption=UNFORMATTED_VALUE&majorDimension=COLUMNS\n```\n\nThe response to this method call consists of an object with the spreadsheet ID\nand an array of\n[`ValueRange`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values#resource:-valuerange)\nobjects corresponding to each requested range, listed in the order they were\nrequested. The\n[`majorDimension`](/workspace/sheets/api/reference/rest/v4/spreadsheets.values) field\nindicates that the arrays are lists of values organized by columns. For example: \n\n```scdoc\n{\n \"spreadsheetId\": SPREADSHEET_ID,\n \"valueRanges\": [\n {\n \"range\": \"Sheet1!A1:D5\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [...],\n [...]\n ]\n },\n {\n \"range\": \"Products!D1:D100\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [...]\n ]\n },\n {\n \"range\": \"Sales!E4:F6\",\n \"majorDimension\": \"COLUMNS\",\n \"values\": [\n [...],\n [...]\n ]\n }\n ]\n}\n```"]]