Excel 多行表头的列转行

Excel中A3:F6是带表头的典型表格,但上面多了额外的两行表头:

|---|---------|---------|-------------|-------------|----------|----------|
| | A | B | C | D | E | F |
| 1 | | | Actuals | Actuals | Plan | Plan |
| 2 | | | FY20 | FY21 | FY20 | FY21 |
| 3 | Country | Owner | 1/1/2020 | 1/1/2020 | 1/1/2020 | 1/1/2020 |
| 4 | France | Richard | 100 | 150 | 80 | 160 |
| 5 | France | Martin | 120 | 140 | 130 | 140 |
| 6 | France | Pierre | 50 | 100 | 50 | 80 |

现在要将典型表格连同额外的两行表头同时进行列转行:

|----|-------------|-----------|-------------|----------|----------|-----------|
| | A | B | C | D | E | F |
| 9 | Country | Owner | Version | Year | Date | Value |
| 10 | France | Richard | Actuals | FY20 | 1/1/2020 | 100 |
| 11 | France | Richard | Actuals | FY21 | 1/1/2020 | 150 |
| 12 | France | Richard | Plan | FY20 | 1/1/2020 | 80 |
| 13 | France | Richard | Plan | FY21 | 1/1/2020 | 160 |
| 14 | France | Martin | Actuals | FY20 | 1/1/2020 | 120 |
| 15 | France | Martin | Actuals | FY21 | 1/1/2020 | 140 |
| 16 | France | Martin | Plan | FY20 | 1/1/2020 | 130 |
| 17 | France | Martin | Plan | FY21 | 1/1/2020 | 140 |
| 18 | France | Pierre | Actuals | FY20 | 1/1/2020 | 50 |
| 19 | France | Pierre | Actuals | FY21 | 1/1/2020 | 100 |
| 20 | France | Pierre | Plan | FY20 | 1/1/2020 | 50 |
| 21 | France | Pierre | Plan | FY21 | 1/1/2020 | 80 |

使用 SPL XLL,输入公式:

复制代码
=spl("=c=transpose(?2),?1.conj( (a=~).m(3:).(a.to(2)|c(#)|~))",A4:F6,C1:F3)

=spl("=c=transpose(?2),?1.conj( (a=~).m(3:).(a.to(2)|c(#)|~))",A4:F6,C1:F3)

transpose将表头 C1:F3 进行转置,conj 合并集合成员,~ 表示表格 A4:F6 每一行,m(3:) 表示从每行的第 3 个成员取到结尾。

相关推荐
wuyk5551 天前
Spider-第09讲-三格式落盘CSV-Excel-JSON
爬虫·python·json·excel
黎羽_2 天前
Excel 插图在手机端不显示/错位:完整排查手册
excel·openpyxl·移动端·办公文档
用户298698530143 天前
React 前端实现 Excel 与 CSV 互转:基于 WebAssembly 的浏览器端方案
javascript·react.js·excel
仓库日记4 天前
Excel进销存何时该换?用3项检查判断是否需要软件
经验分享·excel·进销存·开单软件
用户0332126663674 天前
如何使用 Python 将 JSON 转换为 Excel
python·excel
2601_967980115 天前
Python自动化办公:模块、库与样式调整教程
python·excel·自动化办公·openpyxl·样式调整
用户0332126663675 天前
使用 Python 轻松加密或解密 Excel 文档
python·excel
总裁余(余登武)6 天前
【python项目】:1操作EXCEl自动化开发
python·自动化·excel
ailitsoft9 天前
库存管理系统如何记录跨门店调拨后的收货差异?
excel·零售·软件需求
百事牛科技10 天前
Excel的三种密码:防看、防存、防乱改,各管各的
windows·excel