Type.ForRecord
Type.ForRecord(fields as record, open as logical) as type
返回一个类型,此类型表示对字段具有特定类型约束的记录。
动态生成表类型。
使用情况
let
columnNames = {"Name", "Score"},
columnTypes = {type text, type number},
rowColumnTypes = List.Transform(columnTypes, (t) => [Type = t, Optional = false]),
rowType = Type.ForRecord(Record.FromList(rowColumnTypes, columnNames), false)
in
#table(type table rowType, {{"Betty", 90.3}, {"Carl", 89.5}})
输出
#table(
type table [Name = text, Score = number],
{{"Betty", 90.3}, {"Carl", 89.5}}
)