### Example Pivot Table with Date Data Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Illustrates a pivot table showing sales transactions by date before applying a date-time grouping rule. ```text +----------+--------------+ | Date | SUM of Sales | +----------+--------------+ | 1/1/2017 | $621.14 | | 2/3/2017 | $708.84 | | 5/8/2017 | $326.84 | ... +----------+--------------+ ``` -------------------------------- ### Text Wrapping: Clip Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Shows the `CLIP` text wrap strategy, where text exceeding the cell width is simply cut off. ```text | First sentence. | | Manual newline t| <- Text is clipped | Next newline. | ``` -------------------------------- ### Vertical Text Rotation Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Illustrates how text is displayed when vertical text rotation is applied. Each character occupies its own line. ```text | V | | e | | r | | t | | i | | c | | a | | l | ``` -------------------------------- ### get Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.values Returns a range of values from a spreadsheet. This method allows you to retrieve data from a specific A1 notation range. ```APIDOC ## get ### Description Returns a range of values from a spreadsheet. ### Method GET ### Endpoint /spreadsheets/{spreadsheetId}/values/{range} ### Parameters #### Path Parameters - **spreadsheetId** (string) - Required - The ID of the spreadsheet to retrieve values from. - **range** (string) - Required - The A1 notation of the range to retrieve values from. #### Query Parameters - **majorDimension** (string) - Optional - The major dimension to use for the returned values. - **valueRenderOption** (string) - Optional - How values in the response should be rendered. - **dateTimeRenderOption** (string) - Optional - How datetime values in the response should be rendered. ### Response #### Success Response (200) - **range** (string) - The A1 notation of the range the values cover. - **majorDimension** (string) - The major dimension of the values. - **values** (array of arrays) - The data that was read. #### Response Example ```json { "range": "Sheet1!A1:B2", "majorDimension": "ROWS", "values": [ [ "Value 1", "Value 2" ], [ "Value 3", "Value 4" ] ] } ``` ``` -------------------------------- ### Text Wrapping: Overflow Cell Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Demonstrates the `OVERFLOW_CELL` text wrap strategy where text extends into adjacent cells if they are empty. ```text | First sentence. | | Manual newline that is very long. <- Text continues into next cell | Next newline. | ``` -------------------------------- ### PivotGroup label Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Demonstrates the use of the `label` field for customizing row and column group headers. Shows how 'Region' can be a row label and 'Product' a column label. ```text +--------------+---------+-------+ | SUM of Units | Product | | | Region | Pen | Paper | +--------------+---------+-------+ | New York | 345 | 98 | | Oregon | 234 | 123 | | Tennessee | 531 | 415 | +--------------+---------+-------+ | Grand Total | 1110 | 636 | +--------------+---------+-------+ ``` -------------------------------- ### Text Wrapping: Wrap Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Demonstrates the `WRAP` text wrap strategy, which breaks long words at the character level to fit within the cell width. ```text | Cell has a | | loooooooooo| <- Word is broken. | ong word. | ``` -------------------------------- ### Example Pivot Table with YEAR_MONTH Grouping Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Shows the result of applying a YEAR_MONTH DateTimeRuleType to the date data, grouping sales by year and month. ```text +--------------+--------------+ | Grouped Date | SUM of Sales | +--------------+--------------+ | 2017-Jan | $53,731.78 | | 2017-Feb | $83,475.32 | | 2017-Mar | $94,385.05 | ... +--------------+ ``` -------------------------------- ### Spreadsheets: get Source: https://developers.google.com/workspace/sheets/api/reference/rest Returns the spreadsheet at the given ID. ```APIDOC ## GET /v4/spreadsheets/{spreadsheetId} ### Description Returns the spreadsheet at the given ID. ### Method GET ### Endpoint /v4/spreadsheets/{spreadsheetId} ``` -------------------------------- ### PivotGroup repeatHeadings Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Illustrates the effect of the `repeatHeadings` field for row groupings. When true, higher-level headings are repeated; when false (default), they are minimized. ```text +--------------+ | Q1 | Jan | | | Feb | | | Mar | +--------+-----+ | Q1 Total | +--------------+ ``` -------------------------------- ### Text Wrapping: Legacy Wrap Example Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Illustrates the `LEGACY_WRAP` strategy, which clips words longer than the cell width, similar to older Google Sheets behavior. ```text | Cell has a | | loooooooooo| <- Word is clipped. | word. | ``` -------------------------------- ### ChipRun JSON Representation Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Represents a segment of text that contains a Smart Chip. It defines the start index and the chip itself. ```json { "startIndex": integer, "chip": { object (Chip) } } ``` -------------------------------- ### SourceAndDestination Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Defines the source data and how it should be extended for an autofill operation. ```APIDOC ## SourceAndDestination A combination of a source range and how to extend that source. ### JSON Representation ```json { "source": { "object (GridRange)" }, "dimension": enum (Dimension), "fillLength": integer } ``` ### Fields * `source` (GridRange) - The location of the data to use as the source of the autofill. * `dimension` (Dimension) - The dimension that data should be filled into. * `fillLength` (integer) - The number of rows or columns that data should be filled into. Positive numbers expand beyond the last row or last column of the source. Negative numbers expand before the first row or first column of the source. ``` -------------------------------- ### Spreadsheets Create Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/create Creates a spreadsheet, returning the newly created spreadsheet. ```APIDOC ## spreadsheets.create ### Description Creates a spreadsheet, returning the newly created spreadsheet. ### Method POST ### Endpoint https://sheets.googleapis.com/v4/spreadsheets ### Request Body The request body should contain an instance of `Spreadsheet`. ### Response Body If successful, the response body contains a newly created instance of `Spreadsheet`. ### Authorization Scopes Requires one of the following OAuth scopes: - `https://www.googleapis.com/auth/drive` - `https://www.googleapis.com/auth/drive.file` - `https://www.googleapis.com/auth/spreadsheets` ``` -------------------------------- ### PasteDataRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Inserts data into the spreadsheet starting at a specified coordinate. Supports various paste types, delimiters, and HTML data. ```APIDOC ## PasteDataRequest Inserts data into the spreadsheet starting at the specified coordinate. ### Description Inserts data into the spreadsheet starting at a specified coordinate. Supports various paste types, delimiters, and HTML data. ### JSON Representation ```json { "coordinate": { "object (GridCoordinate)" }, "data": "string", "type": "enum (PasteType)", "delimiter": "string", "html": "boolean" } ``` ### Fields * **coordinate** (`object (GridCoordinate)`) - Required - The coordinate at which the data should start being inserted. * **data** (`string`) - Required - The data to insert. * **type** (`enum (PasteType)`) - Required - How the data should be pasted. Union field `kind`. How to interpret the data, exactly one value must be set. * **delimiter** (`string`) - Optional - The delimiter in the data. Used only if `type` is set to `CUSTOM` or `AUTODETECT`. * **html** (`boolean`) - Optional - True if the data is HTML. ``` -------------------------------- ### DimensionRange JSON Representation Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/DimensionRange This is the JSON representation of a DimensionRange object. It specifies the sheet ID, dimension, and the start and end indexes of the range. ```json { "sheetId": integer, "dimension": enum (Dimension), "startIndex": integer, "endIndex": integer } ``` -------------------------------- ### CreateDeveloperMetadataResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from creating developer metadata. ```APIDOC ## CreateDeveloperMetadataResponse ### Description The response from creating developer metadata. ### Response #### Success Response (200) - **replies** (list of CreateDeveloperMetadataResponse.CreateDeveloperMetadataResponse) - The results of creating developer metadata. This will contain a single CreateDeveloperMetadataResponse object. ``` -------------------------------- ### PasteDataRequest JSON Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Represents a request to insert data into a spreadsheet starting at a specific coordinate. Supports various paste types and delimiters. ```json { "coordinate": { object (GridCoordinate) }, "data": string, "type": enum (PasteType), "delimiter": string, "html": boolean } ``` -------------------------------- ### addTable Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Adds a table. ```APIDOC ## addTable ### Description Adds a table. ### Method POST ### Endpoint /spreadsheets/{spreadsheetId}:batchUpdate ### Request Body - **addTable** (object) - Required - Details for adding a table. - **table** (Table) - The table to add. - **sheetId** (integer) - The ID of the sheet the table is on. - **tableId** (integer) - The ID of the table. - **range** (GridRange) - The range the table occupies. - **style** (TableStyle) - The style of the table. ### Request Example ```json { "requests": [ { "addTable": { "table": { "sheetId": 0, "tableId": 1, "range": { "sheetId": 0, "startRowIndex": 0, "endRowIndex": 10, "startColumnIndex": 0, "endColumnIndex": 5 }, "style": { " 0": { " 0": "HEADER_COLOR", " 1": { "red": 0.8, "green": 0.8, "blue": 0.8 } } } } } } ] } ``` ### Response (Standard BatchUpdateResponse) ``` -------------------------------- ### Chart View Window Options JSON Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Configures the visible range of values for a chart axis. Use `viewWindowMin` and `viewWindowMax` to set explicit bounds, or let the API determine optimal values. ```json { "viewWindowMin": number, "viewWindowMax": number, "viewWindowMode": enum (ViewWindowMode) } ``` -------------------------------- ### UpdateCellsRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Updates all cells in a specified range with new data. You can specify the update area using a starting coordinate or a range. The `fields` parameter determines which CellData fields are updated. ```APIDOC ## UpdateCellsRequest ### Description Updates all cells in a specified range with new data. You can specify the update area using a starting coordinate or a range. The `fields` parameter determines which CellData fields are updated. ### JSON Representation ```json { "rows": [ { object (RowData) } ], "fields": string, "start": { object (GridCoordinate) }, "range": { object (GridRange) } } ``` ### Fields * **rows[]** (`object (RowData)`) - Required - The data to write. * **fields** (`string (FieldMask format)`) - Required - The fields of CellData that should be updated. At least one field must be specified. The root is the CellData; 'row.values.' should not be specified. A single `"*"` can be used as short-hand for listing every field. Union field `area`. The location data should be written. Exactly one value must be set. `area` can be only one of the following: * **start** (`object (GridCoordinate)`) - The coordinate to start writing data at. Any number of rows and columns (including a different number of columns per row) may be written. * **range** (`object (GridRange)`) - The range to write data to. If the data in rows does not cover the entire requested range, the fields matching those set in `fields` will be cleared. ``` -------------------------------- ### CreateDeveloperMetadataResponse Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response Represents the response from creating developer metadata. It includes the created developer metadata object. ```json { "developerMetadata": { object (DeveloperMetadata) } } ``` -------------------------------- ### spreadsheets.values.append Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.values/append Appends values to a spreadsheet. The caller must specify the spreadsheet ID, range, and a valueInputOption. The valueInputOption only controls how the input data will be added to the sheet, not what cell the data starts being written to. ```APIDOC ## spreadsheets.values.append ### Description Appends values to a spreadsheet. The input range is used to search for existing data and find a "table" within that range. Values will be appended to the next row of the table, starting with the first column of the table. ### Method POST ### Endpoint `https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/values/{range}:append` ### Path Parameters * **spreadsheetId** (string) - Required - The ID of the spreadsheet to update. * **range** (string) - Required - The A1 notation of a range to search for a logical table of data. Values are appended after the last row of the table. ### Query Parameters * **valueInputOption** (enum (`ValueInputOption`)) - Required - How the input data should be interpreted. * **insertDataOption** (enum (`InsertDataOption`)) - Optional - How the input data should be inserted. * **includeValuesInResponse** (boolean) - Optional - Determines if the update response should include the values of the cells that were appended. By default, responses do not include the updated values. * **responseValueRenderOption** (enum (`ValueRenderOption`)) - Optional - Determines how values in the response should be rendered. The default render option is `FORMATTED_VALUE`. * **responseDateTimeRenderOption** (enum (`DateTimeRenderOption`)) - Optional - Determines how dates, times, and durations in the response should be rendered. This is ignored if `responseValueRenderOption` is `FORMATTED_VALUE`. The default dateTime render option is `SERIAL_NUMBER`. ### Request Body The request body contains an instance of `ValueRange`. ### Response Body #### Success Response (200) If successful, the response body contains data with the following structure: ```json { "spreadsheetId": string, "tableRange": string, "updates": { object (UpdateValuesResponse) } } ``` * **spreadsheetId** (string) - The spreadsheet the updates were applied to. * **tableRange** (string) - The range (in A1 notation) of the table that values are being appended to (before the values were appended). Empty if no table was found. * **updates** (object (`UpdateValuesResponse`)) - Information about the updates that were applied. ### Authorization Scopes * `https://www.googleapis.com/auth/drive` * `https://www.googleapis.com/auth/drive.file` * `https://www.googleapis.com/auth/spreadsheets` ``` -------------------------------- ### AddTableResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from adding a table. ```APIDOC ## AddTableResponse ### Description The response from adding a table. ### Response #### Success Response (200) - **replies** (list of AddTableResponse.AddTableResponse) - The results of adding a table. This will contain a single AddTableResponse object. ``` -------------------------------- ### CreateDeveloperMetadataResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from creating developer metadata, containing the created metadata. ```APIDOC ## CreateDeveloperMetadataResponse ### Description The response from creating developer metadata. ### JSON Representation ```json { "developerMetadata": { "object (DeveloperMetadata)" } } ``` ### Fields * `developerMetadata` (object: DeveloperMetadata) - The developer metadata that was created. ``` -------------------------------- ### UpdateCellsRequest JSON Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Represents a request to update cells within a specified range or starting from a coordinate. It includes the data to write and a field mask to specify which cell properties to update. If the provided data does not cover the entire range, specified fields will be cleared. ```json { "rows": [ { object (RowData) } ], "fields": string, "start": { object (GridCoordinate) }, "range": { object (GridRange) } } ``` -------------------------------- ### Source and Destination for AutoFill Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Defines the source data and how it should be extended for an autofill operation. Specify the dimension and fill length for the operation. ```json { "source": { object (GridRange) }, "dimension": enum (Dimension), "fillLength": integer } ``` -------------------------------- ### CreateDeveloperMetadataRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Creates developer metadata. ```APIDOC ## CreateDeveloperMetadataRequest ### Description Creates developer metadata. ### Method POST ### Endpoint /spreadsheets/{spreadsheetId}:batchUpdate ### Parameters #### Request Body - **developerMetadata** (DeveloperMetadata) - Required - The developer metadata to create. ``` -------------------------------- ### DeveloperMetadataLookup Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/DataFilter Selects DeveloperMetadata that matches all of the specified fields. This allows for filtering metadata based on various criteria like ID, key, value, visibility, and location. ```APIDOC ## DeveloperMetadataLookup ### Description Selects `DeveloperMetadata` that matches all of the specified fields. For example, if only a metadata ID is specified this considers the `DeveloperMetadata` with that particular unique ID. If a metadata key is specified, this considers all developer metadata with that key. If a key, visibility, and location type are all specified, this considers all developer metadata with that key and visibility that are associated with a location of that type. In general, this selects all `DeveloperMetadata` that match the intersection of all the specified fields; any field or combination of fields may be specified. ### JSON Representation ```json { "locationType": "enum (DeveloperMetadataLocationType)", "metadataLocation": { "object": "DeveloperMetadataLocation" }, "locationMatchingStrategy": "enum (DeveloperMetadataLocationMatchingStrategy)", "metadataId": "integer", "metadataKey": "string", "metadataValue": "string", "visibility": "enum (DeveloperMetadataVisibility)" } ``` ### Fields * `locationType` (`enum` of type `DeveloperMetadataLocationType`): Limits the selected developer metadata to those entries which are associated with locations of the specified type. For example, when this field is specified as `ROW` this lookup only considers developer metadata associated on rows. If the field is left unspecified, all location types are considered. This field cannot be specified as `SPREADSHEET` when the `locationMatchingStrategy` is specified as INTERSECTING or when the `metadataLocation` is specified as a non-spreadsheet location. Spreadsheet metadata cannot intersect any other developer metadata location. This field also must be left unspecified when the `locationMatchingStrategy` is specified as EXACT. * `metadataLocation` (`object` of type `DeveloperMetadataLocation`): Limits the selected developer metadata to those entries associated with the specified location. This field either matches exact locations or all intersecting locations according the specified `locationMatchingStrategy`. * `locationMatchingStrategy` (`enum` of type `DeveloperMetadataLocationMatchingStrategy`): Determines how this lookup matches the location. If this field is specified as EXACT, only developer metadata associated on the exact location specified is matched. If this field is specified to INTERSECTING, developer metadata associated on intersecting locations is also matched. If left unspecified, this field assumes a default value of `INTERSECTING`. If this field is specified, a `metadataLocation` must also be specified. * `metadataId` (`integer`): Limits the selected developer metadata to that which has a matching `DeveloperMetadata.metadata_id`. * `metadataKey` (`string`): Limits the selected developer metadata to that which has a matching `DeveloperMetadata.metadata_key`. * `metadataValue` (`string`): Limits the selected developer metadata to that which has a matching `DeveloperMetadata.metadata_value`. * `visibility` (`enum` of type `DeveloperMetadataVisibility`): Limits the selected developer metadata to that which has a matching `DeveloperMetadata.visibility`. If left unspecified, all developer metadata visible to the requesting project is considered. ``` -------------------------------- ### LineStyle Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Defines the visual properties of a line, including its thickness and dash pattern. ```APIDOC ## LineStyle Properties that describe the style of a line. ### Fields - **width** (integer) - The thickness of the line, in px. - **type** (enum LineDashType) - The dash type of the line. ``` -------------------------------- ### DisplayFormat Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Specifies the preferred display format for a person's name in a Smart Chip. ```APIDOC ## DisplayFormat Preferred display format when available. ### Enums * `DISPLAY_FORMAT_UNSPECIFIED` - Default value, do not use. * `DEFAULT` - Default display format. * `LAST_NAME_COMMA_FIRST_NAME` - Last name, first name display format. * `EMAIL` - Email display format. ``` -------------------------------- ### ManualRule Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Allows manual organization of values in a source data column into buckets with user-defined names. ```APIDOC ## ManualRule ### Description Manually organizes values from a source data column into buckets, each with a specified group name. This is useful for categorizing data based on custom criteria. ### Fields - **groups[]** (object): A list of `ManualRuleGroup` objects, where each object defines a group name and the items from the source data that belong to that group. ``` -------------------------------- ### addSlicer Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Adds a slicer. ```APIDOC ## addSlicer ### Description Adds a slicer. ### Method POST ### Endpoint /spreadsheets/{spreadsheetId}:batchUpdate ### Request Body - **addSlicer** (object) - Required - Details for adding a slicer. - **slicer** (Slicer) - The slicer to add. - **sheetId** (integer) - The ID of the sheet the slicer is on. - **slicerId** (integer) - The ID of the slicer. - **position** (EmbeddedObjectPosition) - The position of the slicer. - **spec** (SlicerSpec) - The slicer's specifications. ### Request Example ```json { "requests": [ { "addSlicer": { "slicer": { "sheetId": 0, "slicerId": 1, "position": { "overlayPosition": { "anchorCell": { "sheetId": 0, "rowIndex": 5, "columnIndex": 5 } } }, "spec": { "dataSourceSheetId": 12345, "columns": [ { "columnOffset": 0, "values": ["Value1", "Value2"] } ] } } } } ] } ``` ### Response (Standard BatchUpdateResponse) ``` -------------------------------- ### iOS/Obj-C: Convert Sheets API Color to UIColor Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/other Converts a Google Type Color proto object to a UIColor object. Handles optional alpha values. ```objectivec // ... static UIColor* fromProto(Color* protocolor) { float red = [protocolor red]; float green = [protocolor green]; float blue = [protocolor blue]; FloatValue* alpha_wrapper = [protocolor alpha]; float alpha = 1.0; if (alpha_wrapper != nil) { alpha = [alpha_wrapper value]; } return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; } // ... ``` -------------------------------- ### TrimWhitespaceResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from trimming whitespace. ```APIDOC ## TrimWhitespaceResponse ### Description The response from trimming whitespace. ### Response #### Success Response (200) - **replies** (list of TrimWhitespaceResponse.TrimWhitespaceResponse) - The results of trimming whitespace. This will contain a single TrimWhitespaceResponse object. ``` -------------------------------- ### AddSlicerResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from adding a slicer. ```APIDOC ## AddSlicerResponse ### Description The response from adding a slicer. ### Response #### Success Response (200) - **replies** (list of AddSlicerResponse.AddSlicerResponse) - The results of adding a slicer. This will contain a single AddSlicerResponse object. ``` -------------------------------- ### spreadsheets.batchUpdate Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate Applies one or more updates to the spreadsheet. Each request is validated before being applied. If any request is not valid then the entire request will fail and nothing will be applied. ```APIDOC ## spreadsheets.batchUpdate ### Description Applies one or more updates to the spreadsheet. Each `request` is validated before being applied. If any request is not valid then the entire request will fail and nothing will be applied. ### Method POST ### Endpoint `https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}:batchUpdate` ### Parameters #### Path Parameters - **spreadsheetId** (string) - Required - The spreadsheet to apply the updates to. #### Request Body - **requests[]** (object (Request)) - Required - A list of updates to apply to the spreadsheet. Requests will be applied in the order they are specified. If any request is not valid, no requests will be applied. - **includeSpreadsheetInResponse** (boolean) - Optional - Determines if the update response should include the spreadsheet resource. - **responseRanges[]** (string) - Optional - Limits the ranges included in the response spreadsheet. Meaningful only if `includeSpreadsheetInResponse` is 'true'. - **responseIncludeGridData** (boolean) - Optional - True if grid data should be returned. Meaningful only if `includeSpreadsheetInResponse` is 'true'. This parameter is ignored if a field mask was set in the request. ### Response Body #### Success Response (200) - **spreadsheetId** (string) - The spreadsheet the updates were applied to. - **replies[]** (object (Response)) - The reply of the updates. This maps 1:1 with the updates, although replies to some requests may be empty. - **updatedSpreadsheet** (object (Spreadsheet)) - The spreadsheet after updates were applied. This is only set if `BatchUpdateSpreadsheetRequest.include_spreadsheet_in_response` is `true`. ### Authorization scopes - `https://www.googleapis.com/auth/drive` - `https://www.googleapis.com/auth/drive.file` - `https://www.googleapis.com/auth/spreadsheets` ``` -------------------------------- ### AddChartResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from adding a chart. ```APIDOC ## AddChartResponse ### Description The response from adding a chart. ### Response #### Success Response (200) - **replies** (list of AddChartResponse.AddChartResponse) - The results of adding a chart. This will contain a single AddChartResponse object. ``` -------------------------------- ### POST spreadsheets.developerMetadata.search Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.developerMetadata/search Use this HTTP request to search for developer metadata within a spreadsheet. The request body must include a `dataFilters` array to specify the search criteria. ```HTTP POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}/developerMetadata:search ``` -------------------------------- ### Java: Convert Sheets API Color to java.awt.Color Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/other Converts a Google Type Color proto object to a java.awt.Color object. Handles optional alpha values. ```java import com.google.type.Color; // ... public static java.awt.Color fromProto(Color protocolor) { float alpha = protocolor.hasAlpha() ? protocolor.getAlpha().getValue() : 1.0; return new java.awt.Color( protocolor.getRed(), protocolor.getGreen(), protocolor.getBlue(), alpha); } // ... ``` -------------------------------- ### Response Body for Developer Metadata Search Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.developerMetadata/search A successful response to a developer metadata search request will return a JSON object containing a `matchedDeveloperMetadata` field. This field is an array of `MatchedDeveloperMetadata` objects, each representing metadata that matched the search criteria. ```JSON { "matchedDeveloperMetadata": [ { object (MatchedDeveloperMetadata) } ] } ``` -------------------------------- ### ChartDateTimeRule Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Allows you to organize the date-time values in a source data column into buckets based on selected parts of their date or time values. ```APIDOC ## ChartDateTimeRule ### Description Allows you to organize the date-time values in a source data column into buckets based on selected parts of their date or time values. ### JSON Representation ```json { "type": "enum (ChartDateTimeRuleType)" } ``` ### Fields * `type` | `enum (ChartDateTimeRuleType)`: The type of date-time grouping to apply. ``` -------------------------------- ### createDeveloperMetadata Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Creates new developer metadata entries associated with a spreadsheet or its components. ```APIDOC ## createDeveloperMetadata ### Description Creates new developer metadata ### Method (Not specified, typically POST for batch updates) ### Endpoint (Not specified, typically part of a batchUpdate call) ### Parameters #### Request Body - **request** (CreateDeveloperMetadataRequest) - Required - The request body specifying the developer metadata to create. ``` -------------------------------- ### AddSheetResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response The response from adding a sheet. ```APIDOC ## AddSheetResponse ### Description The response from adding a sheet. ### Response #### Success Response (200) - **replies** (list of AddSheetResponse.AddSheetProperties) - The results of adding a sheet. This will contain a single AddSheetProperties object. ``` -------------------------------- ### autoFill Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Automatically fills in more data based on existing data within a range. ```APIDOC ## autoFill ### Description Automatically fills in more data based on existing data. ### Method (Not specified, typically POST for batch updates) ### Endpoint (Not specified, typically part of a batchUpdate call) ### Parameters #### Request Body - **request** (AutoFillRequest) - Required - The request body specifying the source and destination ranges for the auto-fill. ``` -------------------------------- ### ColorStyle Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/other Represents a color value, which can be either an RGB color or a theme color. ```APIDOC ## ColorStyle A color value. ### JSON representation ```json { "rgbColor": { "object": "Color" }, "themeColor": "enum (ThemeColorType)" } ``` ### Fields * `rgbColor` (`object` (`Color`)): RGB color. The `alpha` value in the `Color` object isn't generally supported. * `themeColor` (`enum` (`ThemeColorType`)): Theme color. ``` -------------------------------- ### batchGet Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.values Returns one or more ranges of values from a spreadsheet. This method allows for efficient retrieval of data from multiple specified ranges. ```APIDOC ## batchGet ### Description Returns one or more ranges of values from a spreadsheet. ### Method GET ### Endpoint /spreadsheets/{spreadsheetId}/values:batchGet ### Parameters #### Path Parameters - **spreadsheetId** (string) - Required - The ID of the spreadsheet to retrieve values from. #### Query Parameters - **ranges** (array of strings) - Required - The A1 notation of the ranges to retrieve values from. - **majorDimension** (string) - Optional - The major dimension to use for the returned values. - **valueRenderOption** (string) - Optional - How values in the response should be rendered. - **dateTimeRenderOption** (string) - Optional - How datetime values in the response should be rendered. ### Response #### Success Response (200) - **spreadsheetId** (string) - The ID of the spreadsheet. - **valueRanges** (array of objects) - The data from the requested ranges. - **range** (string) - The A1 notation of the range the values cover. - **majorDimension** (string) - The major dimension of the values. - **values** (array of arrays) - The data that was read. #### Response Example ```json { "spreadsheetId": "YOUR_SPREADSHEET_ID", "valueRanges": [ { "range": "Sheet1!A1:B2", "majorDimension": "ROWS", "values": [ [ "Value 1", "Value 2" ], [ "Value 3", "Value 4" ] ] } ] } ``` ``` -------------------------------- ### addDataSource Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Adds a data source. ```APIDOC ## addDataSource ### Description Adds a data source. ### Method POST ### Endpoint /spreadsheets/{spreadsheetId}:batchUpdate ### Request Body - **addDataSource** (object) - Required - Details for adding a data source. - **dataSource** (DataSource) - The data source to add. - **dataSourceId** (string) - The ID of the data source. - **lookupUri** (string) - The URI of the data source. - **dataSourceObject** (DataSourceObject) - The data source object. ### Request Example ```json { "requests": [ { "addDataSource": { "dataSource": { "dataSourceId": "my-data-source", "lookupUri": "https://example.com/data", "dataSourceObject": { " 0": { " 0": "ColumnA", " 1": "ColumnB" } } } } } ] } ``` ### Response (Standard BatchUpdateResponse) ``` -------------------------------- ### Add Data Source Request Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Use this request to add a data source to the spreadsheet. A `DATA_SOURCE` sheet will be created, and an execution will refresh it. Requires `bigquery.readonly` scope for BigQuery data sources. ```json { "dataSource": { object (DataSource) } } ``` -------------------------------- ### Batch Update Request Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate Defines the structure for a batch update request, including a list of individual requests, and options for including the spreadsheet in the response. ```json { "requests": [ { object (Request) } ], "includeSpreadsheetInResponse": boolean, "responseRanges": [ string ], "responseIncludeGridData": boolean } ``` -------------------------------- ### KeyValueFormat Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Formatting options for key-value pairs in charts. It allows customization of text format and horizontal positioning. ```APIDOC ## KeyValueFormat Formatting options for key value. ### JSON Representation ```json { "textFormat": { object (TextFormat) }, "position": { object (TextPosition) } } ``` ### Fields * `textFormat` (object (`TextFormat`)) - Text formatting options for key value. The link field is not supported. * `position` (object (`TextPosition`)) - Specifies the horizontal text positioning of key value. This field is optional. If not specified, default positioning is used. ``` -------------------------------- ### PieChartSpec Object Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Configuration for a pie chart, including legend position, data sources for domain and series, and 3D rendering options. ```APIDOC ## Object: PieChartSpec A pie chart. ### Fields * `legendPosition` (enum PieChartLegendPosition): Where the legend of the pie chart should be drawn. * `domain` (object ChartData): The data that covers the domain of the pie chart. * `series` (object ChartData): The data that covers the one and only series of the pie chart. * `threeDimensional` (boolean): True if the pie is three dimensional. * `pieHole` (number): The size of the hole in the pie chart. ``` -------------------------------- ### UpdateDeveloperMetadataResponse Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response Represents the response from updating developer metadata. It returns an array of the updated developer metadata objects. ```json { "developerMetadata": [ { object (DeveloperMetadata) } ] } ``` -------------------------------- ### Spreadsheets.getByDataFilter Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/getByDataFilter Returns the spreadsheet at the given ID. The caller must specify the spreadsheet ID. This method differs from spreadsheets.get in that it allows selecting which subsets of spreadsheet data to return by specifying a `dataFilters` parameter. Multiple `DataFilters` can be specified. Specifying one or more data filters returns the portions of the spreadsheet that intersect ranges matched by any of the filters. By default, data within grids is not returned. You can include grid data in one of two ways: Specify a field mask listing your desired fields using the `fields` URL parameter in HTTP. Set the `includeGridData` parameter to `true`. If a field mask is set, the `includeGridData` parameter is ignored. For large spreadsheets, as a best practice, retrieve only the specific spreadsheet fields that you want. ```APIDOC ## spreadsheets.getByDataFilter ### Description Returns the spreadsheet at the given ID using data filters to specify which subsets of data to return. This method allows for selective retrieval of spreadsheet data. ### Method POST ### Endpoint `https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}:getByDataFilter` ### Path Parameters - **spreadsheetId** (string) - Required - The spreadsheet to request. ### Request Body - **dataFilters** (array of objects) - Required - The `DataFilters` used to select which ranges to retrieve from the spreadsheet. - **includeGridData** (boolean) - Optional - True if grid data should be returned. This parameter is ignored if a field mask was set in the request. - **excludeTablesInBandedRanges** (boolean) - Optional - True if tables should be excluded in the banded ranges. False if not set. ### Response Body - **Spreadsheet** - If successful, the response body contains an instance of `Spreadsheet`. ``` -------------------------------- ### CreateDeveloperMetadataRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request A request to create developer metadata. The metadata to be created is specified in the request body. ```APIDOC ## CreateDeveloperMetadataRequest ### Description A request to create developer metadata. ### JSON Representation ```json { "developerMetadata": { "object": "DeveloperMetadata" } } ``` ### Fields * `developerMetadata` (object: DeveloperMetadata) - The developer metadata to create. ``` -------------------------------- ### MatchedDeveloperMetadata Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.developerMetadata/search The `MatchedDeveloperMetadata` object links developer metadata to the specific data filters that caused it to be included in the search results. It contains the `developerMetadata` itself and the `dataFilters` that matched. ```JSON { "developerMetadata": { object (DeveloperMetadata) }, "dataFilters": [ { object (DataFilter) } ] } ``` -------------------------------- ### View Window Mode Enum Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Specifies how the minimum and maximum values of a chart's view window are interpreted. `PRETTY` mode automatically adjusts for optimal visual appearance. ```json { "DEFAULT_VIEW_WINDOW_MODE": "The default view window mode used in the Sheets editor for this chart type. In most cases, if set, the default mode is equivalent to `PRETTY`.", "VIEW_WINDOW_MODE_UNSUPPORTED": "Do not use. Represents that the currently set mode is not supported by the API.", "EXPLICIT": "Follows the min and max exactly if specified. If a value is unspecified, it will fall back to the `PRETTY` value.", "PRETTY": "Chooses a min and max that make the chart look good. Both min and max are ignored in this mode." } ``` -------------------------------- ### WrapStrategy Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Defines how text should wrap within a cell, including options for overflow, legacy wrapping, clipping, and standard word wrapping. ```APIDOC ## WrapStrategy How to wrap text in a cell. ### Enums * `WRAP_STRATEGY_UNSPECIFIED`: The default value, do not use. * `OVERFLOW_CELL`: Lines longer than the cell width overflow into adjacent empty cells. Behaves like `CLIP` if the next cell is not empty. Text does not wrap to the next line unless manually inserted. * `LEGACY_WRAP`: Represents the old Google Sheets wrap strategy where long words are clipped instead of broken. This strategy is not supported on all platforms and is being phased out. * `CLIP`: Lines longer than the cell width are clipped. Text does not wrap to the next line unless manually inserted. * `WRAP`: Words longer than a line are wrapped at the character level rather than clipped. ``` -------------------------------- ### ManualRuleGroup Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/pivot-tables Defines a group name and the list of items from the source data that should be placed into that group. ```APIDOC ## ManualRuleGroup ### Description Specifies a name for a group and lists the source data items that should be assigned to this group. ### Fields - **groupName** (object): The name of the group. This must be a string, and each group name within a `ManualRule` must be unique. - **items[]** (object): The items from the source data that will be placed into this group. Items can be strings, numbers, or booleans. Each item can only appear in one group within a `ManualRule`. Items not assigned to any group will appear individually. ``` -------------------------------- ### AutoFillRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Fills in data automatically. ```APIDOC ## AutoFillRequest ### Description Fills in data automatically. ### Method POST ### Endpoint /spreadsheets/{spreadsheetId}:batchUpdate ### Parameters #### Request Body - **range** (GridRange) - Required - The range to fill. - **sourceAndDestination** (SourceAndDestination) - Required - The source and destination for the fill. ``` -------------------------------- ### AutoFillRequest Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Fills in more data based on existing data within a specified range or source/destination. ```APIDOC ## AutoFillRequest Fills in more data based on existing data. ### JSON Representation ```json { "useAlternateSeries": boolean, "range": { "object (GridRange)" }, "sourceAndDestination": { "object (SourceAndDestination)" } } ``` ### Fields * `useAlternateSeries` (boolean) - True if we should generate data with the "alternate" series. This differs based on the type and amount of source data. * `area` (Union): The area to autofill. Can be either `range` or `sourceAndDestination`. * `range` (GridRange) - The range to autofill. This will examine the range and detect the location that has data and automatically fill that data in to the rest of the range. * `sourceAndDestination` (SourceAndDestination) - The source and destination areas to autofill. This explicitly lists the source of the autofill and where to extend that data. ``` -------------------------------- ### ChartAxisViewWindowOptions Object Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/charts Options that define a 'view window' for a chart, controlling the visible values in an axis. ```APIDOC ## Object: ChartAxisViewWindowOptions The options that define a "view window" for a chart (such as the visible values in an axis). ### JSON Representation ```json { "viewWindowMin": number, "viewWindowMax": number, "viewWindowMode": enum (ViewWindowMode) } ``` ### Fields * `viewWindowMin` (number): The minimum numeric value to be shown in this view window. If unset, will automatically determine a minimum value that looks good for the data. * `viewWindowMax` (number): The maximum numeric value to be shown in this view window. If unset, will automatically determine a maximum value that looks good for the data. * `viewWindowMode` (enum (ViewWindowMode)): The view window's mode. It defines how to treat the min and max of the view window. ``` -------------------------------- ### AddSlicerResponse Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response Represents the result of successfully adding a slicer to a spreadsheet. It includes the details of the newly created slicer. ```APIDOC ## AddSlicerResponse ### Description The result of adding a slicer to a spreadsheet. ### JSON Representation ```json { "slicer": { "object (Slicer)" } } ``` ### Fields * `slicer` (object (`Slicer`)) - The newly added slicer. ``` -------------------------------- ### Text Format Run JSON Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells Defines the JSON structure for a run of text with a specific format. The format applies from the startIndex until the next run. ```json { "startIndex": integer, "format": { object (TextFormat) } } ``` -------------------------------- ### Copy Paste Request Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request Copies data from a source range to a destination range. Data will be repeated if the destination range is a multiple of the source's dimensions. ```json { "source": { object (GridRange) }, "destination": { object (GridRange) }, "pasteType": enum (PasteType), "pasteOrientation": enum (PasteOrientation) } ``` -------------------------------- ### AddBandingResponse Structure Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/response Represents the result of adding a banded range. It returns the newly added banded range object. ```json { "bandedRange": { object (BandedRange) } } ``` -------------------------------- ### Java: Convert java.awt.Color to Sheets API Color Source: https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/other Converts a java.awt.Color object to a Google Type Color proto object. Sets alpha only if it's not fully opaque. ```java import com.google.type.Color; // ... public static Color toProto(java.awt.Color color) { float red = (float) color.getRed(); float green = (float) color.getGreen(); float blue = (float) color.getBlue(); float denominator = 255.0; Color.Builder resultBuilder = Color .newBuilder() .setRed(red / denominator) .setGreen(green / denominator) .setBlue(blue / denominator); int alpha = color.getAlpha(); if (alpha != 255) { result.setAlpha( FloatValue .newBuilder() .setValue(((float) alpha) / denominator) .build()); } return resultBuilder.build(); } // ... ```