openpyxl.worksheet.cell_range.
CellRange
(
range_string=None
,
min_col=None
,
min_row=None
,
max_col=None
,
max_row=None
,
title=None
)
[source]
¶
Bases:
openpyxl.descriptors.serialisable.Serialisable
Represents a range in a sheet: title and coordinates.
This object is used to perform operations on ranges, like:
We can check whether a range is:
We can get:
bottom
¶
A list of cell coordinates that comprise the bottom of the range
bounds
¶
Vertices of the range as a tuple
cells
¶
cols
¶
Return cell coordinates as columns
coord
¶
Excel-style representation of the range
expand
(
right=0
,
down=0
,
left=0
,
up=0
)
[source]
¶
Expand the range by the dimensions provided.
| 参数: |
|
|---|
intersection
(
other
)
[source]
¶
Return a new range with cells common to this range and other
| 参数: | other ( openpyxl.worksheet.cell_range.CellRange ) – Other sheet range. |
|---|---|
| 返回: | the intersecting sheet range. |
| Raise: |
ValueError
若
other
range doesn’t intersect
with this range.
|
isdisjoint
(
other
)
[source]
¶
返回
True
if this range has no cell in common with
other
. Ranges are disjoint if and only if their intersection is the empty range.
| 参数: | other ( openpyxl.worksheet.cell_range.CellRange ) – Other sheet range. |
|---|---|
| 返回: |
True
if the range has no cells in common with other.
|
issubset
(
other
)
[source]
¶
Test whether every cell in this range is also in other .
| 参数: | other ( openpyxl.worksheet.cell_range.CellRange ) – Other sheet range |
|---|---|
| 返回: |
True
if
range
<=
other
.
|
issuperset
(
other
)
[source]
¶
Test whether every cell in other is in this range.
| 参数: | other ( openpyxl.worksheet.cell_range.CellRange ) – Other sheet range |
|---|---|
| 返回: |
True
if
range
>=
other
(或
other
in
range
).
|
left
¶
A list of cell coordinates that comprise the left-side of the range
max_col
¶
Values must be of type <class ‘int’>
max_row
¶
Values must be of type <class ‘int’>
min_col
¶
Values must be of type <class ‘int’>
min_row
¶
Values must be of type <class ‘int’>
right
¶
A list of cell coordinates that comprise the right-side of the range
rows
¶
Return cell coordinates as rows
shift
(
col_shift=0
,
row_shift=0
)
[source]
¶
Shift the focus of the range according to the shift values ( col_shift , row_shift ).
| 参数: |
|
|---|---|
| Raise: |
ValueError
if any row or column index < 1
|
shrink
(
right=0
,
bottom=0
,
left=0
,
top=0
)
[source]
¶
Shrink the range by the dimensions provided.
| 参数: |
|
|---|
size
¶
Return the size of the range as a dictionary of rows and columns.
top
¶
A list of cell coordinates that comprise the top of the range
union
(
other
)
[source]
¶
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
.
| 参数: | other ( openpyxl.worksheet.cell_range.CellRange ) – Other sheet range. |
|---|---|
| 返回: |
a
CellRange
that is a superset of this and
other
.
|
openpyxl.worksheet.cell_range.
MultiCellRange
(
ranges=()
)
[source]
¶
Bases:
openpyxl.descriptors.Strict
ranges
¶
A sequence (list or tuple) that may only contain objects of the declared type