某表格 A 列是编号,其他列是用逗号分隔的意义不同的分类列
A | B | C | D | E | F | G | |
1 | Assembly# | ProductType | Unit Config | Nominal Capacity | Supply Voltage | Generation | Case Construction |
2 | 3H1012290001 | CM | D,P | 24,36 | F | A | A,B |
3 | 3H1012290002 | CM | D,P | 48,60 | F | A,B | A,B |
4 | 3H1012290003 | CM | D,P | 24,36 | B,C,D,E | A | A,B |
要求展开各分类列,并互相组合。比如第一条数据的处理结果
A | B | C | D | E | F | G | |
6 | Assembly# | ProductType | Unit Config | Nominal Capacity | Supply Voltage | Generation | Case Construction |
7 | 3H1012290001 | CM | D | 24 | F | A | A |
8 | 3H1012290001 | CM | D | 24 | F | A | B |
9 | 3H1012290001 | CM | D | 36 | F | A | A |
10 | 3H1012290001 | CM | D | 36 | F | A | B |
11 | 3H1012290001 | CM | P | 24 | F | A | A |
12 | 3H1012290001 | CM | P | 24 | F | A | B |
13 | 3H1012290001 | CM | P | 36 | F | A | A |
14 | 3H1012290001 | CM | P | 36 | F | A | B |
使用 SPL XLL,输入公式:
=spl("=E@b(?.(~.(~.split@c())).conj(eval($[xjoin(] / ~.($[~(] / # / $[)]).concat($[;]) / $[)])))",A2:G4)
函数 E@b()将表格的非列名部分转为序列。split@c 用逗号将字符串拆为序列。conj 合并成员。eval 把字符串当作代码动态执行。xjoin 将多个序列叉乘 / 组合起来。$[;] 是字符串的简写形式,等价于 "";""
标签:ProductTypeUnit,Excel,序列,split,循环展开,字符串,VoltageGenerationCase,conj,多列 From: https://blog.csdn.net/smilejingwei/article/details/139603213