getReferencedValues
Description
returns the values of the Safety Analysis Manager spreadsheet referenced cells
that the cell, values
= getReferencedValues(spreadsheetCell
)spreadsheetCell
, references.
Examples
Retrieve Referenced Cell Values
Create two Safety Analysis Manager spreadsheets, and store each
Spreadsheet
object 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 column and derived column that have custom labels to the
mySpreadsheet2
spreadsheet by using the addColumn
function.
addColumn(mySpreadsheet2,Count=2,Type=["text","derived"]... ,Label=["Check Box Column","Derived Column"])
Add a check box column that has a custom label to the
mySpreadsheet1
spreadsheet by using the addColumn
function.
addColumn(mySpreadsheet1,Type="checkbox",Label="Check Box Column")
Save the spreadsheets.
save(mySpreadsheet1,"spreadsheet1.mldatx") save(mySpreadsheet2,"spreadsheet2.mldatx")
Retrieve the SperadsheetCell
objects for the first cells in the
first and second column in the mySpreadsheet1
spreadsheet and the
first cell in the derived column in the mySpreadsheet2
spreadsheet.
myCell1(1) = getCell(mySpreadsheet1,1,1);
myCell1(2) = getCell(mySpreadsheet1,1,2);
myCell2 = getCell(mySpreadsheet2,1,"Derived Column");
Assign values to the cells in the mySpreadsheet1
spreadsheet.
myCell1(1).Value = "value 1";
myCell1(2).Value = true;
Create a reference where the myCell2
cell references the
myCell1
cells by using the addReference
function.
addReference(myCell2,myCell1)
Retrieve the referenced cell values.
myCellReferenceValues = getReferencedValues(myCell2)
myCellReferenceValues = 1×2 cell array {'value 1'} {[1]}
Input Arguments
spreadsheetCell
— Spreadsheet cell
SpreadsheetCell
object
Spreadsheet cell to add the reference to, specified as a
SpreadsheetCell
object. The cell must be in a derived column. For
more information on derived columns, see Define Derived Values and Define the Derived Column Formula.
Output Arguments
values
— Referenced cell values
cell array
Referenced cell values, returned as a cell array. Each entry in the cell array can contain these values, depending on the column type:
Column Type | Value Type | More Information |
---|---|---|
Text | Character vector | Add Rows and Columns to a Spreadsheet |
Check Box | Logical 1 (true ) or
0 (false ) | Create a Check Box Column |
Enumeration | Enumeration contained in an enumeration class | |
Derived | Character vector that contains the output of the column formula | Create a Derived Column That Outputs Based on Two Column Values |
The cell array lists the referenced cell values in the order of the references. To
adjust the order, use the moveReference
function.
Version History
Introduced in R2024b
See Also
Objects
Functions
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)