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 个成员取到结尾。

相关推荐
CodeCraft Studio5 小时前
Excel处理控件Aspose.Cells教程:使用 Python 在 Excel 中进行数据验
开发语言·python·excel
时间之城5 小时前
笔记:记一次使用EasyExcel重写convertToExcelData方法无法读取@ExcelDictFormat注解的问题(已解决)
java·spring boot·笔记·spring·excel
VBAMatrix6 小时前
审计效率升级!快速匹配Excel报表项目对应的Word附注序号
excel·审计·财务报表·会计师事务所·审计工具
lovely_nn7 小时前
wps excel 常用操作
excel·wps
前端极客探险家10 小时前
前端 Excel 工具组件实战:导入 → 可编辑表格 → 导出 + 样式同步 + 单元格合并
前端·typescript·vue·excel
AAA顶置摸鱼12 小时前
使用 Pandas 进行多格式数据整合:从 Excel、JSON 到 HTML 的处理实战
json·excel·pandas
神奇侠20242 天前
基于PaddleOCR对图片中的excel进行识别并转换成word(一)
python·word·excel·paddleocr
林枫依依2 天前
Unity 将Excel表格中的数据导入到Mysql数据表中
数据库·mysql·excel
CodeJourney.2 天前
基于DeepSeek与Excel的动态图表构建:技术融合与实践应用
数据库·人工智能·算法·excel
神奇侠20242 天前
基于PaddleOCR对图片中的excel进行识别并转换成word优化(二)
opencv·excel·paddleocr