# Cell

The cell(rowNum, colNum) function gets or sets values in the active worksheet or matrix. Indicate the row number and column number in parentheses. 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.

Cell is an older LabTalk function, and in newer versions of Origin, other methods to access the cell contents of a worksheet are provided:

## Function Form:

 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 = embedding graph (embedding:Graph Name) 9 = embedding matrix book (embedding:Matrix Name) 10 = embedding notes (embedding:Note Name) 11 = embedding EMF(embedding: EMF xxx) 12 = embedding BMP(embedding: LBmp xxx) 13 = DDE (DDE://) Notes: • Links like range://, http:// etc. will return 0 since their values can be directly accessed. • To return the raw reference string, use cell(rowNum, colNum, 1)$:
cell(1,2,1)$=; // for example, returns the raw reference at row 1, column 2, as a string ## Examples: 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)\$=;};