{"updateCells":{"rows":[{"values":[{"userEnteredValue":{"stringValue":"@ is the owner of @."},"chipRuns":[{"chip":{"personProperties":{"email":"johndoe@gmail.com","displayFormat":"DEFAULT"}}},{"startIndex":18,"chip":{"richLinkProperties":{"uri":"https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit"}}}]}]}],"fields":"userEnteredValue,chipRuns","range":{"startRowIndex":0,"startColumnIndex":0}}}
配置芯片属性
功能块对象可以具有以下属性类型之一:
personProperties
使用此功能创建人物晶片。
email:(必需)要关联的人员的电子邮件地址。
displayFormat:(可选)人员姓名的首选显示格式。可以是以下各项之一:
DEFAULT:标准“名字 姓氏”格式。
LAST_NAME_COMMA_FIRST_NAME:“姓氏,名字”格式。
EMAIL:相应人员的电子邮件地址。
richLinkProperties
使用此方法可创建富链接芯片。虽然该 API 可以读取指向各种 Google 服务(例如 YouTube 或 Google 日历)的链接,但只有指向 Google 云端硬盘文件的链接可以作为功能块写入。
uri:(必需)资源的 URI。对于写作,这必须是 Google 云端硬盘文件链接。URI 不得超过 2000 字节。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Smart chips\n\nThis guide describes how and why to use the Google Sheets API to add and manage smart chips in your spreadsheets.\n\nWhat is a smart chip?\n---------------------\n\nWith smart chips, you can bring rich, interactive data from other Google Workspace applications directly into Sheets. Smart chips provide users with quick access to information and actions, transforming a cell link into a dynamic object. To learn more, see [Insert smart chips in your Google Sheets](https://support.google.com/docs/answer/12319513).\n\nAdd a smart chip\n----------------\n\nChips are represented as chip runs, which are part of [CellData](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/cells#CellData), so you can insert a chip using the existing [`spreadsheets.batchUpdate`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/batchUpdate) method by supplying an [`UpdateCellsRequest`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#UpdateCellsRequest) or [`AppendCellsRequest`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#AppendCellsRequest).\n\nThe request must include the `chipRuns` field. A chip run describes a chip's properties and where it is located within the cell's text.\n\nWhen writing `chipRuns`, you must also provide a `userEnteredValue` that contains placeholder characters (`@`) for each chip you intend to add. Each run in the `chipRuns` array will correspond to one of the placeholders. Non-chipped runs can be omitted on write.\n\nThe following example shows how to write a file chip, a people chip, and plain text into a single cell, A1.\n\\* {JSON} \n\n {\n \"updateCells\": {\n \"rows\": [\n {\n \"values\": [\n {\n \"userEnteredValue\": {\n \"stringValue\": \"@ is the owner of @.\"\n },\n \"chipRuns\": [\n {\n \"chip\": {\n \"personProperties\": {\n \"email\": \"johndoe@gmail.com\",\n \"displayFormat\": \"DEFAULT\"\n }\n }\n },\n {\n \"startIndex\": 18,\n \"chip\": {\n \"richLinkProperties\": {\n \"uri\": \"https://docs.google.com/document/d/YOUR_DOCUMENT_ID/edit\"\n }\n }\n }\n ]\n }\n ]\n }\n ],\n \"fields\": \"userEnteredValue,chipRuns\",\n \"range\": {\n \"startRowIndex\": 0,\n \"startColumnIndex\": 0\n }\n }\n }\n\n### Configure chip properties\n\nA chip object can have one of the following property types:\n\n#### personProperties\n\nUse this to create a person chip.\n\n- `email`: (Required) The email address of the person to link.\n- `displayFormat`: (Optional) The preferred display format for the person's name. Can be one of the following:\n - `DEFAULT`: Standard \"First Name Last Name\" format.\n - `LAST_NAME_COMMA_FIRST_NAME`: \"Last Name, First Name\" format.\n - `EMAIL`: The person's email address.\n\n#### richLinkProperties\n\nUse this to create a rich link chip. While the API can read links to various Google services (like YouTube or Calendar), only links to Google Drive files can be written as chips.\n\n- `uri`: (Required) The URI of the resource. For writing, this must be a Google Drive file link. URIs cannot exceed 2000 bytes.\n\n| **Note:** Writing Drive file chips requires your application to be authorized with at least one of the `drive.file`, `drive.readonly`, or `drive` OAuth scopes.\n\nRead a smart chip\n-----------------\n\nTo read a smart chip's data, use the [`spreadsheets.get`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/get) method and include `sheets.data.rowData.values(chipRuns)` in the fields parameter.\n\nThe `chipRuns` array in the response will contain objects for all subsections of the cell's text.\n\n- Chipped runs: These sections will have a populated `chip` object containing either `personProperties` or `richLinkProperties`.\n- Non-chipped runs: Plain text sections will also have a run object, but its `chip` field will be empty.\n\nTo get the display text of a chip, add `formattedValue` as a field.\n\nUpdate a smart chip\n-------------------\n\nTo update or replace a smart chip, you have to overwrite the cell's contents. Use the same [`UpdateCellsRequest`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#UpdateCellsRequest) or [`AppendCellsRequest`](https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets/request#AppendCellsRequest) as you would for adding a chip, providing a new `userEnteredValue` and `chipRun`. This will replace the existing chip in the cell.\n| **Important:** Writing a new `userEnteredValue` to a cell will erase all previous `chipRuns` from that cell. You must supply a new set of runs to persist or modify the chips.\n\nUse smart chips with other Sheets features\n------------------------------------------\n\n[Tables](https://developers.google.com/workspace/sheets/api/guides/tables): Smart chips can be used as a table column type to track project owners (People chip), or related documents (File chip).\n\n[Filters](https://developers.google.com/workspace/sheets/api/guides/filters): You can filter ranges based on the text value of the smart chips within them."]]