Main Content

addRow

Add row to spreadsheet in Safety Analysis Manager

Since R2023b

Description

addRow(spreadsheet) adds a row to the spreadsheet, spreadsheet, in the Safety Analysis Manager.

example

addRow(spreadsheet,Name=Value) adds a row or rows to the spreadsheet using one or more name-value arguments.

example

Examples

collapse all

Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add a row to the spreadsheet.

addRow(mySpreadsheet)

Create a new spreadsheet in the Safety Analysis Manager.

mySpreadsheet = safetyAnalysisMgr.newSpreadsheet;

Add two rows to the spreadsheet.

addRow(mySpreadsheet,Count=2)

Add a third row between the rows that you added.

addRow(mySpreadsheet,Position=3)

Input Arguments

collapse all

Spreadsheet in the Safety Analysis Manager, specified as a Spreadsheet object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: addRow(mySpreadsheet,Count=3) adds three new rows to the bottom of the Spreadsheet object, mySpreadsheet.

Index of the new row, specified as a positive integer. The index of the topmost row of the spreadsheet is 1. To find the number or rows in the spreadsheet, retrieve the Rows property of the Spreadsheet object used in spreadsheet.

Example: addRow(mySpreadsheet,Position=2) inserts a new row into the second index of the Spreadsheet object, mySpreadsheet.

Example: addRow(mySpreadsheet,Position=mySpreadsheet.Rows + 1) adds a row to the bottom of the Spreadsheet object, mySpreadsheet.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Number of rows to add to the spreadsheet, specified as a positive integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Value of the cells in the row, specified as a cell array. Each value corresponds to the index in the column. The data type for each array entry you can specify depends on the column type:

Column TypeValue
TextString scalar or character vector
Check boxNumeric or logical 1 (true) or 0 (false)
EnumerationString scalar, character vector, or explicit value specified by an enumeration class

You cannot set the values of cells in derived columns.

Tips

  • Add a row to the top of the spreadsheet by setting index to 1.

  • Add a row to the bottom of the spreadsheet by setting index to the value of the Spreadsheet object Rows property plus 1, or by omitting the Position name value argument.

  • This function does not return a SpreadsheetRow object. To retrieve the SpreadsheetRow object of the row you add, use the getRow function on the Spreadsheet object with the index that you specify in the Position name-value argument. (since R2024b)

Version History

Introduced in R2023b