|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- // output
- let
- Source = Excel.CurrentWorkbook(){[Name="表2"]}[Content],
- rows = List.Buffer(Table.ToList(Source)&{"款号"}),
- n = List.Count(rows),
- gen = List.Generate(
- ()=>
- {null, {}, null},
- each (_{0}<n)?? true,
- each let i=_{0}+1??0
- in {
- i,
- if Text.StartsWith(rows{i}, "款号") then { Text.Trim(rows{i}, {" ",""""})} else _{1}&{Text.Trim(rows{i}, {" ",""""})},
- if _{1}={} then null
- else if Text.StartsWith(rows{i}, "款号")
- then let row_inn=List.RemoveItems(_{1}, {"", "合格证"}),
- trans=fnTrans(row_inn),
- tbl=let lists=List.Zip(trans) in Table.FromRows({lists{1}}, lists{0})
- in tbl else null
- },
-
- each _{2}
- ),
- tbl = Table.Combine(List.RemoveNulls(gen)),
- result = Table.ReorderColumns(tbl, List.Sort(Table.ColumnNames(tbl), each List.PositionOf(ord_list, _, 0, (x,y)=>Text.Contains(y,x))))
- in
- result
- // fnTrans
- (row_inn)=>
- List.Accumulate(
- row_inn,
- {{}, {}},
- (s,c)=>if s{0}={} then {c, {}}
- else if Text.Contains(c, ":") then {c, s{1}&{ Text.Split(s{0}, ":")}}
- else {s{0}&c, s{1}}){1}&{{"零售价", null}}
- // ord_list
- let
- Source = {"款号", "执行", "品类", "技术", "品名", "号型", "质量", "检验员", "产地", "成分", "维护", "注", "零售价"}
- in
- Source
复制代码
|
评分
-
2
查看全部评分
-
|