Raised when - a requested range / named range / table column is invalid or cannot be found - usage of a Range instance fails due to its dimensions, e.g. Range.set() with too many values
Returns a list-of-lists representation in the form:
[[row values,...], [row values,...], ...]
All row lists have the same length. The number of rows / columns returned may be less than num_rows / num_columns; the fetch is clipped to the ‘used range’ of the worksheet
Updates the matrix’s cells. data should be of the form:
[[row values, ...], [row values,...], ...]
Not all rows and columns need to be specified; the given values fill the top-left corner of the matrix, and the remaining cells are unchanged. For example:
workbook.get("A:C").set([[1,2], [3,4]])
only modifies A1:B2
Represents a contiguous range of cells in Excel, ex. A1:B20. The contents (in Excel) can be read and written to (see the get and set methods).
Ranges are usually obtained using the xl.sheet.Workbook.get() or xl.sheet.Workbook.range() method. The returned range behaves according to its ‘shape,’ which is reflected in its type as well as the shape property:
>>> type(workbook.get("A:A"))
<class 'xl.range.ColumnVector'>
A range’s shape may be ColumnVector, RowVector, Scalar, or Matrix. The Vector type (a base for RowVector and ColumnVector) allows detection of either vector variety:
>>> isinstance(workbook.get("A:A"), xl.Vector)
True
The shape subclasses differ in the rules and types involved in accessing the backing Excel data, e.g. the return type of get. See help(shape class) for specifics.
By default, a Range excludes ‘hidden’ cells - those not visible in Excel due to an Excel-level filter, or manual hiding by the user. The including_hidden and excluding_hidden properties permit explicit control of this behavior:
>>> workbook.get("A1:A3")
<ColumnVector range object for $A$1,$A$3 (visible only)>
>>> workbook.get("A1:A3").including_hidden
<ColumnVector range object for $A$1:$A$3 (includes hidden)>
Note that un-filtered dimensions determine shape, e.g. workbook.get("A1:B2") is a Matrix, even if column B is hidden
Returns a version of this range that is always a Matrix (even if shaped differently). This is useful for utility functions that wish to avoid a special case per range shape
Returns the sheet-wide column index of the left-most unfiltered cells
Returns one of the column-vectors comprising this Range by index, i.e. column_vector(0) gives the first column
If this range is partially or fully contained in a Table, returns the table Otherwise, returns None
Gives the tuple (num rows, num columns). If applicable for this range, hidden cells are excluded
Returns a new Range identical this one, but with hidden cells filtered away. This is reversible, e.g. range.exluding_hidden.including_hidden
Returns a new Range identical this one, but with hidden cells included. This is reversible, e.g. range.including_hidden.excluding_hidden
Returns a generator yielding the single cell ranges comprising this scalar / vector. Thus, range.get() == [c.get() for c in range.itercells()]
Return a normalized version of this range. The returned range is reduced to encompass only in-use areas of the worksheet, and (if applicable) the data area of its table
Returns the sheet-wide row index of the top-most unfiltered cells
Returns one of the row-vectors comprising this Range by index, i.e. row_vector(0) gives the first row
Returns the shape class of this range (e.g. RowVector). Equivalent to type(self)
Returns a range with the specified inclusion / exclusion of hidden cells. See the including_hidden / excluding_hidden properties for less verbose shortcuts
Returns the single value in the scalar range.
Updates this scalar range’s cell. The data parameter may be a single value, or a (non-string) iterable that returns one item.
Returns a list representation of this vector’s values (containing values for low indices first)
The number of elements returned may be less than num_rows / num_columns; the fetch is clipped to the ‘used range’ of the worksheet
Updates this vector’s cells. The data parameter should be an iterable returning cell values. Not all cells need to be specified. Values are filled in from the top-left of the vector, and additional cells are left unmodified. For example:
workbook.get("A:A").set([1,2,3])
sets the first 3 values of column A