閱讀英文

共用方式為


Type.ForRecord

語法

Type.ForRecord(fields as record, open as logical) as type

關於

使用欄位的特定類型條件約束,傳回代表記錄的類型。

範例 1

動態產生資料表類型。

使用方式

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}}
)