跳至主要内容

Table.InsertRows

將資料列清單插入資料表中的指定位置。

Syntax

Table.InsertRows(
table as table,
offset as number,
rows as list
) as table

Remarks

傳回資料表,其中資料列清單 rows 已插入 table 中的指定位置 offset。要插入之資料列中的每個資料行都必須符合資料表的資料行類型。

Examples

Example #1

將資料列插入資料中的位置 1。

Table.InsertRows(
Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}),
1,
{[CustomerID = 3, Name = "Paul", Phone = "543-7890"]}
)

Result:

Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})

Example #2

將兩個資料列插入資料中的位置 1。

Table.InsertRows(
Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
1,
{
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}
)

Result:

Table.FromRecords({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Category

Table.Row operations