Main Content

SpreadsheetCell

Cell in spreadsheet in Safety Analysis Manager

Since R2023b

Description

SpreadsheetCell objects represent cells in spreadsheets in the Safety Analysis Manager. Use SpreadsheetCell objects to configure spreadsheet cell properties you use in safety analyses.

Creation

To create a SpreadsheetCell object:

Properties

expand all

This property is read-only.

Row location of the cell in the spreadsheet, returned as a positive integer. The row index of the topmost row of the spreadsheet is 1.

Data Types: uint64

This property is read-only.

Column location of the cell in the spreadsheet, returned as a positive integer. The column index of the leftmost column of the spreadsheet is 1.

Data Types: uint64

This property is read-only.

Label of the column in the spreadsheet that contains the cell, returned as a character vector.

Data Types: char

Value of the cell, specified as a character vector, a numeric or logical 1 (true) or 0 (false), or an enumeration class value. The value type that you can specify depends on the column type that contains the cell:

Column TypeValue TypeMore Information
TextString scalar or character vectorAdd Rows and Columns to a Spreadsheet
Check BoxLogical true (1) or false (0)Create a Check Box Column
EnumerationString scalar, character vector, or explicit value specified by an enumeration class
DerivedString scalar derived from the output of the column formulaCreate a Derived Column That Outputs Based on Two Column Values

Data Types: char | logical | string

Cell description, specified as a string scalar or character vector.

Data Types: char | string

Object Functions

acceptAllChangesAccept detected changes to linked artifacts in Safety Analysis Manager
addFlagAdd flag to Safety Analysis Manager spreadsheet cell or row
addReferenceAdd references to cells
clearFlagsClear flags in Safety Analysis Manager spreadsheet
getChangesGet changed artifacts linked to artifacts in Safety Analysis Manager
getFlagsRetrieve flags from Safety Analysis Manager spreadsheets
getLinksGet links associated with spreadsheet cell or row in Safety Analysis Manager
getReferencedValuesGet referenced cell values
getReferencesGet referenced cells
getRowRetrieve spreadsheet rows
getSpreadsheetRetrieve spreadsheet containing specified cell
moveReferenceChange order of references
removeReferenceRemove references in Safety Analysis Manager spreadsheets

Examples

collapse all

Suppose that only one spreadsheet is loaded in the Safety Analysis Manager. Retrieve the Spreadsheet object of the spreadsheet.

mySpreadsheet = safetyAnalysisMgr.getOpenDocuments;

Retrieve the cell in the second row and the second column of the spreadsheet as a SpreadsheetCell object.

myCell = getCell(mySpreadsheet,2,2);

Set the cell value to This is a value.

myCell.Value = "This is a value";

Since R2024b

Create two Safety Analysis Manager spreadsheets, and store each Spreadsheet objects in a variable.

mySpreadsheet1 = safetyAnalysisMgr.newSpreadsheet;
mySpreadsheet2 = safetyAnalysisMgr.newSpreadsheet;

Add three rows to each spreadsheet by using the addRow function.

addRow(mySpreadsheet1,Count=3)
addRow(mySpreadsheet2,Count=3)

Add a text and derived column that have custom labels to the spreadsheet assigned to mySpreadsheet2 by using the addColumn function.

addColumn(mySpreadsheet2,Count=2,Type=["text","derived"]...
  ,Label=["Text Column","Derived Column"])

Save the spreadsheets.

save(mySpreadsheet1,"spreadsheet1.mldatx")
save(mySpreadsheet2,"spreadsheet2.mldatx")

Retrieve the SpreadsheetCell objects for the first cell in the mySpreadsheet1 spreadsheet and the first cell in the derived column in the mySpreadsheet2 spreadsheet.

myCell1 = getCell(mySpreadsheet1,1,1);
myCell2 = getCell(mySpreadsheet2,1,"Derived Column");

Create a reference where the myCell2 cell references the myCell1 cell by using the addReference function.

addReference(myCell2,myCell1)

Retrieve the CellReference object of the referenced cell by using the getReferences function on the myCell2 cell.

mySourceCells = getReferences(myCell2);
mySourceCells{1}
ans = 

  CellReference with properties:

       FileName: 'C:\spreadsheet2.mldatx'
            Row: 1
         Column: 1
    ColumnLabel: 'Label1'
          Value: ''

Limitations

  • The SpreadsheetCell objects that you use is derived column formulas are read-only.

Version History

Introduced in R2023b

expand all