Excel 识别数据层次后转换成表格

某列数据可分为 3 层,第 1 层是字符串,第 2 层是日期,第 3 层是时间:

|----|------------|
| | A |
| 1 | NAME1 |
| 2 | 2024-06-03 |
| 3 | 04:06:12 |
| 4 | 04:09:23 |
| 5 | 08:09:23 |
| 6 | 12:09:23 |
| 7 | 17:02:23 |
| 8 | 2024-06-02 |
| 9 | 04:06:12 |
| 10 | 04:09:23 |
| 11 | 08:09:23 |
| 12 | NAME2 |
| 13 | 2024-06-03 |
| 14 | 04:06:12 |
| 15 | 04:09:23 |
| 16 | 2024-06-02 |
| 17 | 12:09:23 |
| 18 | 17:02:23 |

需要正确识别三层数据,并转为规范的表格:

|----|-------|------------|----------|
| | D | E | F |
| 1 | NAME1 | 2024-06-03 | 04:06:12 |
| 2 | NAME1 | 2024-06-03 | 04:09:23 |
| 3 | NAME1 | 2024-06-03 | 08:09:23 |
| 4 | NAME1 | 2024-06-03 | 12:09:23 |
| 5 | NAME1 | 2024-06-03 | 17:02:23 |
| 6 | NAME1 | 2024-06-02 | 04:06:12 |
| 7 | NAME1 | 2024-06-02 | 04:09:23 |
| 8 | NAME1 | 2024-06-02 | 08:09:23 |
| 9 | NAME2 | 2024-06-03 | 04:06:12 |
| 10 | NAME2 | 2024-06-03 | 04:09:23 |
| 11 | NAME2 | 2024-06-02 | 12:09:23 |
| 12 | NAME2 | 2024-06-02 | 17:02:23 |

使用 SPL XLL,输入公式:

复制代码
=spl("=E@1(?).(if(ifstring(~):s=~, if(ifdate(E(~))):d=~; [s,d,~])).select(ifa(~))",A1:A18)

spl返回的日期类型为整数形式,需用 Excel 的 "format cells" 功能(或 spl 的 E 函数)格式化为易读形式,时间类型同样处理。

函数 E 可转换 Excel 的日期时间类型,E@1 将多层序列转为单层。~ 表示当前成员。if 函数从左到右依次判断真假并执行表达式,最后执行缺省表达式。ifa 判断变量是否为序列。

相关推荐
wtsolutions10 小时前
JSON to Excel Add-in - Seamless Integration Within Excel
json·excel
wtsolutions10 小时前
Getting Started with JSON to Excel Web App - Convert in Seconds
json·excel·web app
wtsolutions14 小时前
Using the JSON to Excel API - Programmatic Access for Developers
json·excel
qq_4351395714 小时前
EasyExcel(FastExcel)Excel导出功能 技术文档
excel
wtsolutions17 小时前
Understanding JSON Formats - What JSON to Excel Supports
json·excel
wtsolutions17 小时前
Advanced Features - Unlocking the Power of JSON to Excel Pro
linux·json·excel
fs哆哆19 小时前
VB.NET和VBA教程-如何查找Excel数据区域边界
excel
小矮强19 小时前
Excel中根据年月日提取月日,并按月日进行排序
excel
开开心心_Every19 小时前
图片批量压缩工具:支持有损无损两种模式
python·游戏·微信·django·pdf·excel·语音识别
wtsolutions20 小时前
Real-World Use Cases - How Organizations Use JSON to Excel
json·excel