v, t = xlsx.GetCellValue(id, x, y[, sheet]) v, t = xlsx.GetCellValue(id, ref[, sheet])
x
and y
arguments. Those
positions start from 1 for the first column and row. Alternatively, you
can also specify the cell by passing its reference in the ref
parameter. This can either
be a string, e.g. "A10" for the first cell in the 10th row, or an iterator state returned
by the xlsx.CellRange() function. Optionally, you can also pass the index of the worksheet to
use in the optional sheet
parameter (starting from 1 for the first worksheet). If
the sheet
parameter is omitted, the worksheet set by xlsx.SetDefaultSheet()
will be used.
xlsx.GetCellValue()
returns two values: The actual cell value in the first return
value and the cell value type in the second return value. The return value type
will be one of the following special constants:
#INTEGER
#DOUBLE
#STRING
#BOOLEAN
True
or False
).
#NIL
#VOID
NaN
or a logical error like division by zero.
Note that when trying to get the values of many cells it's usually much faster to use the xlsx.CellRange() function together with a generic for loop to iterate over the desired cells. This is especially recommended when dealing with large XLSX documents that have thousands of cells.
x
and y
are omittedxlsx.Open(1, "test.xlsx") cols = xlsx.GetColumnCount(1) rows = xlsx.GetRowCount(1) For Local y = 1 To rows For Local x = 1 to cols DebugPrint((xlsx.GetCellValue(1, x, y))) Next DebugPrint("************************") Next xlsx.Close(1)The code above opens
test.xlsx
and prints the values of all cells.