You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google表格中将多个Smart Chip合并至单个单元格?

按团队合并多个Smart Chip到单个单元格的解决方案

直接使用TEXTJOIN、INDEX/MATCH或VLOOKUP这类内置函数无法实现需求——这些函数只会提取Smart Chip的文本值(比如邮箱),而非保留Chip对象本身。要实现合并后仍保留Smart Chip格式,需借助Google Apps Script:

  1. 打开目标Google表格,点击菜单栏「扩展」→「Apps脚本」
  2. 替换默认代码为以下脚本(示例中姓名Smart Chip在A列、团队在B列,合并结果写入C列,可根据你的表格结构调整列索引):
function mergeTeamSmartChips() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const dataRange = sheet.getDataRange();
  const values = dataRange.getValues();
  const teamChipsMap = new Map();

  // 按团队分组收集Smart Chip的富文本对象
  for (let rowIdx = 1; rowIdx < values.length; rowIdx++) {
    const teamName = values[rowIdx][1]; // B列:团队名称
    const chipCell = sheet.getRange(rowIdx + 1, 1); // A列:姓名Smart Chip所在单元格
    const chipRichText = chipCell.getRichTextValue();

    if (!teamChipsMap.has(teamName)) {
      teamChipsMap.set(teamName, []);
    }
    teamChipsMap.get(teamName).push(chipRichText);
  }

  // 将分组后的Smart Chip合并写入目标列(C列)
  let targetRow = 2;
  teamChipsMap.forEach((chips, team) => {
    const targetCell = sheet.getRange(targetRow, 3);
    const combinedRichText = SpreadsheetApp.newRichTextValue();
    
    chips.forEach((chip, idx) => {
      if (idx > 0) {
        combinedRichText.appendText(", ").setTextStyle(SpreadsheetApp.newTextStyle().build());
      }
      // 保留原Smart Chip的文本和样式
      combinedRichText.appendText(chip.getText()).setTextStyle(chip.getTextStyle());
    });

    targetCell.setRichTextValue(combinedRichText.build());
    targetRow++;
  });
}
  1. 保存脚本并运行,授权必要权限后,即可在目标列得到按团队合并、且保留Smart Chip格式的结果。

注意:目前Google表格的内置函数体系中,没有原生支持合并Smart Chip对象的功能,脚本是唯一可行的方案。

内容的提问来源于stack exchange,提问作者Ken

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 04:07:08