本帖最后由 papshaw 于 2024-8-14 17:40 编辑
先插入自定义列内容DateTime.LocalNow(),然后用空格拆分刚插入的这列为日期和时间两列,然后合并这两列,中间留出空格,再加载到Excel里就可以了。下面是Lot list查询的代码,日期是按YY-MM-DD格式来的,你可以自己再做转换。
let
Source = Excel.Workbook(File.Contents("C:\Users\ccxcsz2\Desktop\数据源\Lot list.xlsx"), null, true),
#"Lot list_Sheet" = Source{[Item="Lot list",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(#"Lot list_Sheet", [PromoteAllScalars=true]),
#"Merged Queries" = Table.NestedJoin(#"Promoted Headers", {"LotID"}, Machine, {"LotID"}, "Machine", JoinKind.LeftOuter),
#"Expanded Machine" = Table.ExpandTableColumn(#"Merged Queries", "Machine", {"Operation1", "Operation2"}, {"Operation1", "Operation2"}),
已添加自定义 = Table.AddColumn(#"Expanded Machine", "自定义", each DateTime.LocalNow()),
按分隔符拆分列 = Table.SplitColumn(Table.TransformColumnTypes(已添加自定义, {{"自定义", type text}}, "zh-Hans"), "自定义", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"自定义.1", "自定义.2"}),
合并的列 = Table.CombineColumns(按分隔符拆分列,{"自定义.1", "自定义.2"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"刷新完成时间")
in
合并的列
|