如何将文字拆分后扩展成多行
Excel中D列和E列有多行文字,两者行数相同且一一对应,比如F对应Fail。
A |
B |
C |
D |
E |
|
1 |
Names |
Class |
Year |
Grades |
Comment |
2 |
Name1 |
2nd |
2012 |
A |
Very Good, Needs Improvement |
3 |
Name2 |
4th |
2012 |
F |
Fail |
4 |
Name3 |
5th |
2012 |
A |
Very Good, Needs Improvement |
计算目标:将D列和E列按换行符拆分,并扩展成多行,结果应当如下。
A |
B |
C |
D |
E |
|
1 |
Names |
Class |
Year |
Grades |
Comment |
2 |
Name1 |
2nd |
2012 |
A |
Very Good, Needs Improvement |
3 |
Name1 |
2nd |
2012 |
F |
Fail |
4 |
Name1 |
2nd |
2012 |
C |
Satisfactory |
5 |
Name2 |
4th |
2012 |
F |
Fail |
6 |
Name2 |
4th |
2012 |
F |
Fail |
7 |
Name3 |
5th |
2012 |
A |
Very Good, Needs Improvement |
8 |
Name3 |
5th |
2012 |
B |
Good, Needs Improvement |
9 |
Name3 |
5th |
2012 |
C |
Satisfactory |
实现步骤:
1. 运行集算器(可以到润乾官网下载,用职场版,首次运行时会提示加载授权,下载个免费的就够了)
2. 编写脚本并执行
A |
|
1 |
=file("data.xlsx").xlsimport@t() |
2 |
=A1.run(Grades=Grades.split("\n"),Comment=Comment.split("\n")) |
3 |
=A2.news(Grades.len();Names,Class,Year,Grades(#):Grades,Comment(#):Comment) |
4 |
=file("result.xlsx").xlsexport@t(A3) |
脚本函数news可将一行扩展成多行,其中Grades.len()计算原来每行可扩展出的新行的行数,# 是新行的行号,Grades(#) 按行号取出每个新行。