CellRange
paper-xlsx 0.2.1 API reference
Represents a range in a sheet: title and coordinates.
This object is used to perform operations on ranges, like:
- shift, expand or shrink
- union/intersection with another sheet range,
We can check whether a range is:
- equal or not equal to another,
- disjoint of another,
- contained in another.
We can get:
- the size of a range.
- the range bounds (vertices)
- the coordinates,
- the string representation,
CellRange(range_string=None, min_col=None, min_row=None, max_col=None, max_row=None, title=None)Attributes
bottom
attributebottomA list of cell coordinates that comprise the bottom of the range
bounds
attributeboundsVertices of the range as a tuple
cells
attributecellscols
attributecolsReturn cell coordinates as columns
coord
attributecoordExcel-style representation of the range
idx_base
attributeidx_base= 0left
attributeleftA list of cell coordinates that comprise the left-side of the range
max_col
attributemax_col= max_colmax_row
attributemax_row= max_rowmin_col
attributemin_col= min_colmin_row
attributemin_row= min_rownamespace
attributenamespace= Noneright
attributerightA list of cell coordinates that comprise the right-side of the range
rows
attributerowsReturn cell coordinates as rows
size
attributesizeReturn the size of the range as a dictionary of rows and columns.
tagname
attributetagnametitle
attributetitle= titletop
attributetopA list of cell coordinates that comprise the top of the range
Functions
__contains__
func__contains__(coord)Check whether the range contains a particular cell coordinate
paramcoord__iter__
func__iter__()For use as a dictionary elsewhere in the library.
expand
funcexpand(right=0, down=0, left=0, up=0)Expand the range by the dimensions provided.
paramrightint= 0expand range to the right by this number of cells
paramdownint= 0expand range down by this number of cells
paramleftint= 0expand range to the left by this number of cells
paramupint= 0expand range up by this number of cells
from_tree
funcfrom_tree(node)Create object from XML
paramnodeintersection
funcintersection(other)Return a new range with cells common to this range and other
Raises
ValueError: if the other range doesn't intersect with this range.
paramotheropenpyxl.worksheet.cell_range.CellRangeOther sheet range.
Returns
Not annotatedthe intersecting sheet range.
isdisjoint
funcisdisjoint(other)Return True if this range has no cell in common with other.
Ranges are disjoint if and only if their intersection is the empty range.
paramotheropenpyxl.worksheet.cell_range.CellRangeOther sheet range.
Returns
Not annotatedTrue if the range has no cells in common with other.
issubset
funcissubset(other)Test whether every cell in this range is also in other.
paramotheropenpyxl.worksheet.cell_range.CellRangeOther sheet range
Returns
Not annotatedTrue if range <= other.
issuperset
funcissuperset(other)Test whether every cell in other is in this range.
paramotheropenpyxl.worksheet.cell_range.CellRangeOther sheet range
Returns
Not annotatedTrue if range >= other (or other in range).
shift
funcshift(col_shift=0, row_shift=0)Shift the focus of the range according to the shift values (col_shift, row_shift).
Raises
ValueError: if any row or column index < 1
paramcol_shiftint= 0number of columns to be moved by, can be negative
paramrow_shiftint= 0number of rows to be moved by, can be negative
shrink
funcshrink(right=0, bottom=0, left=0, top=0)Shrink the range by the dimensions provided.
paramrightint= 0shrink range from the right by this number of cells
parambottom= 0paramleftint= 0shrink range from the left by this number of cells
paramtop= 0to_tree
functo_tree(tagname=None, idx=None, namespace=None)paramtagname= Noneparamidx= Noneparamnamespace= Noneunion
funcunion(other)Return the minimal superset of this range and other. This new range
will contain all cells from this range, other, and any additional
cells required to form a rectangular CellRange.
paramotheropenpyxl.worksheet.cell_range.CellRangeOther sheet range.
Returns
Not annotateda CellRange that is a superset of this and other.