- let
- 源 = Excel.CurrentWorkbook(){[Name="表1"]}[Content],
- 更改的类型 = Table.TransformColumnTypes(源,{{"组合型材编号(名称)", type text}, {"名称", type text}, {"型号", type text}, {"颜色", type text}, {"长度", Int64.Type}, {"数量", Int64.Type}, {"余料", type text}}),
- 向下填充 = Table.FillDown(更改的类型,{"颜色", "长度", "数量", "余料"}),
- 筛选的行 = Table.SelectRows(向下填充, each ([名称] <> null)),
- 按照字符转换拆分列 = Table.SplitColumn(筛选的行, "名称", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"名称.1", "名称.2"}),
- 删除的列 = Table.RemoveColumns(按照字符转换拆分列,{"组合型材编号(名称)", "型号"}),
- 被除的列 = Table.TransformColumns(删除的列, {{"长度", each _ / 1000, type number}}),
- 去除的文本 = Table.TransformColumns(Table.TransformColumnTypes(被除的列, {{"长度", type text}, {"数量", type text}}, "zh-CN"),{{"名称.1", Text.Trim, type text}, {"名称.2", Text.Trim, type text}, {"颜色", Text.Trim, type text}, {"长度", Text.Trim, type text}, {"数量", Text.Trim, type text}, {"余料", Text.Trim, type text}}),
- 清除的文本 = Table.TransformColumns(去除的文本,{{"名称.1", Text.Clean, type text}, {"名称.2", Text.Clean, type text}, {"颜色", Text.Clean, type text}, {"长度", Text.Clean, type text}, {"数量", Text.Clean, type text}, {"余料", Text.Clean, type text}}),
- 重命名的列 = Table.RenameColumns(清除的文本,{{"名称.1", "型号"}, {"名称.2", "名称"}})
- in
- 重命名的列
复制代码
|