語法
Table.FromList(
list as list,
optional splitter as nullable function,
optional columns as any,
optional default as any,
optional extraValues as nullable number
) as table
關於
將清單list中的每個項目透過選擇性應用進行處理,然後轉換成資料表splitter。 根據預設,清單會假設為以逗號分隔的文字值清單。 可選的columns可以是欄位數目、欄位清單或 TableType。 還可指定選擇性 default 和 extraValues。
範例 1
使用預設分隔器,從清單建立資料表。
使用方式
Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
null,
{"Letter", "Example Word"}
)
輸出
Table.FromRecords({
[Letter = "a", #"Example Word" = "apple"],
[Letter = "b", #"Example Word" = "ball"],
[Letter = "c", #"Example Word" = "cookie"],
[Letter = "d", #"Example Word" = "door"]
})
範例 2
使用自訂分隔器,從清單建立資料表。
使用方式
Table.FromList(
{"a,apple", "b,ball", "c,cookie", "d,door"},
Splitter.SplitByNothing(),
{"Letter and Example Word"}
)
輸出
Table.FromRecords({
[#"Letter and Example Word" = "a,apple"],
[#"Letter and Example Word" = "b,ball"],
[#"Letter and Example Word" = "c,cookie"],
[#"Letter and Example Word" = "d,door"]
})
範例 3
使用 Record.FieldValues 分割器從清單中建立數據表。
使用方式
Table.FromList(
{
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
},
Record.FieldValues,
{"CustomerID", "Name"}
)
輸出
Table.FromRecords({
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
})