The cell() function gets or sets values in the active worksheet or matrix. Arguments are row number, cell number and optionally, a reference argument that returns information about cell contents.
To specify a name of the specific worksheet/matrix, use the notation: winName!cell(rowNum, colNum). This notation is not supported for other worksheet functions.
Beginning with Origin 2019, the function returns the value as displayed in the cell, overriding the column Display. |
Cell is an older LabTalk function. The user should know that in
newer versions of Origin, other methods to access the cell contents of
a worksheet are supported:
Cell(rowNum, colNum[,reference]), or Cell(rowNum, colNum[,reference])$
or
winName!Cell(rowNum, colNum[,reference])
Setting optional parameter reference = 1, returns information about linked cells (e.g. whether a cell is linked; what the linked cell contains):
cell(1,1,1); // for example, returns type of cell reference in row 1, column 1 0 = not a cell reference 1 = cell link (cell://) 2 = formula (=) 3 = var link (var://) 4 = str link (str://) 5 = file link (file://) 6 = graph link (graph://) 7 = matrix link (matrix://) 8 = embedded graph (embedding:Graph Name) 9 = embedded matrixbook (embedding:Matrix Name) 10 = embedded notes (embedding:Note Name) 11 = inserted EMF(EMF xxx) 12 = inserted BMP(LBmp xxx) 13 = DDE (DDE://) 14 = inserted OpenCV image (MED xxx)
Notes:
cell(rowNum, colNum,
1)$
:cell(1,2,1)$=; // for example, returns the raw reference at row 1, column 2, as a string
Example 1
In the following example, the variable %W is assigned the value in row 50 of the third column in the active worksheet (or matrix).
%W = cell(50, 3)$;
If no sheet is specified, active sheet is assumed:
[book1]!Cell(2,4)=;
One can specify a particular sheet such as:
[book1]sheet2!Cell(2,4)=;
Example 2
In the following example, the fifth cell in the second column in the Matrix3 is assigned to the value 100.
Matrix3!cell(5, 2) = 100;
Example 3
The following sample script loops over the active sheet checking column 2 for linked cells, returns a reference value (see above) corresponding to the type of link in cell and returns the link as a string.
loop(ii, 1, 11){cell(ii,2,1)=;cell(ii,2,1)$=;};