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

Google Sheets 如何将表头行转换为对应非空行的重复映射值

Google Sheets 实现表头行转换为重复行值的操作

原始表格结构

行号A列B列C列D列E列
1Email 1Email 2Email 3Email 4Email 5
2some@email.combutt@cheeks.comcolumn@c.comone@for.comalmost@done.com
3another@that.comfart@face.comnot@d.comthe@money.comthe@end.com
4okay@that.commuch@typing.comtwo@for.comsome@email.com
5all@different.comboring@example.com
6who@cares.comsome@email.com
7tidious@question.com

预期输出效果

行号A列B列
1EmailEmail ID
2some@email.comEmail 1
3some@email.comEmail 2
4some@email.comEmail 5
5another@that.comEmail 1
6okay@that.comEmail 1
7all@different.comEmail 1
8who@cares.comEmail 1
9tidious@question.comEmail 1
10butt@cheeks.comEmail 2
11fart@face.comEmail 2
12much@typing.comEmail 2
13boring@example.comEmail 2
14column@c.comEmail 3
15not@d.comEmail 3
16one@for.comEmail 4
17the@money.comEmail 4
18two@for.comEmail 4
19almost@done.comEmail 5
20the@end.comEmail 5

实现方案

在任意空白工作表的A1单元格粘贴以下公式,回车后即可自动生成完整的标准化结果:

={
  {"Email", "Email ID"};
  HSTACK(
    TOCOL(A2:E7, 1),
    TOCOL(IF(A2:E7<>"", A1:E1, ""), 1)
  )
}

公式逻辑说明

  • TOCOL(范围, 1):将多列横向数据批量拉成单列,第二个参数1表示自动忽略空单元格
  • IF(A2:E7<>"", A1:E1, ""):逐单元格判断原始数据是否为空,非空则返回对应列的表头值,空值返回空字符串,避免匹配错位
  • HSTACK(列1, 列2):将处理好的邮箱值列和对应表头列横向拼接为最终的两列结构
  • 若后续需要新增原始数据,可将公式中的固定范围A2:E7改为动态范围A2:E,即可自动抓取A到E列第2行以下的所有非空数据,无需手动调整公式范围

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.29 22:45:04