CGrid:GetRow
The GetRow method returns an array containing the values in a row. The array of row data starts at index 1.
array = G:GetRow( nRow )
array = G:GetRow( nRow, nCols )
array = G:GetRow( nRow, nColMin, nColMax )
where
nRow is the row index. Data is retreived from all columns in the row.
nCols is the number of columns to retrieve, starting at column 1. The column range is clipped to the range [1, GetNumCols].
nColMin, nColMax are the indices of the beginning and ending columns to retrieve. The column range is clipped to the range [1, GetNumCols].
array is a Lua array containing the data. On failure, nil is returned.
The following script creates a grid and stores numbers in columns 1 through 5 and rows 1 through 3. The script retrieves data from all of row 3:
|
-- new grid with 3 cols, 10 rows, 1 Sheet |
|
-- set 5 columns in row 1 |
|
-- set 5 columns in row 2 |
|
-- set 5 columns in row 3 |
|
-- fetch data from row 3 |
|
-- do for each row |
|
-- result: 5, 6, 7, 8, 9 |
|
|
The following script creates a grid like the one above. The script retrieves data from row 3 between nColMin=2 and nColMax=400, which is beyond the end of the grid. Notice that the grid starts at index 1 whereas the data start at column nColMin :
|
-- new grid with 3 cols, 10 rows, 1 Sheet |
|
-- set 5 columns in row 1 |
|
-- set 5 columns in row 2 |
|
-- set 5 columns in row 3 |
|
-- select columns 2 through 400 |
|
-- get row 3, starting at column 2 |
|
-- do for each column |
|
-- result: 6, 7, 8, 9 |
|
|