Skip to main content
Version: v6.5.0

Insert row

Command Description

Insert a new row above the specified row in the data table and fill it with data

Command Prototype

Datatable.InsertRow(dtTable, index, objDefaultValue)

Command parameter

parametermandatorytypedefault valueInstructions
dtTableTrueexpressionobjDatatableThe data table object newly inserted into a row and filled with data, usually the return value of the "Build Data Table" command or the "Build Data Table from Excel Table" command
indexTruenumberoneSpecify which row already exists in the data table, or add 1 to the maximum number of rows as the position, and insert a new row above this position
objDefaultValueTrueexpression[]Support filling array format data into inserted new rows, and the length of the array must be equal to the number of columns; It also supports filling with the same single value; If you do not want to fill in the content, you can keep it as the default value (empty array), and finally insert a new empty text line

Return result

Run instance

/*********************************Insert Row*****************************************
Command Prototype:
Datatable.InsertRow(dtTable, index, objDefaultValue)
Input Parameters:
dtTable -- Data table object. Note: The data table object that will have a new row inserted and filled with data, typically the return value of the "Build Data Table" command or the "Build Data Table from Excel" command.
index -- Row position. Note: Specifies the position above which to insert the new row, either at an existing row position (the nth row) or at the maximum row count plus 1.
objDefaultValue -- Row data. Note: Supports filling the new row with array-formatted data (the array length must equal the number of columns), or filling with the same single value. If no content is desired, it can remain as the default value (empty array), resulting in an empty text row.
Output Parameters:
None
Notes:
None
********************************************************************************/
Datatable.InsertRow(objDatatable, 1, [])