Range class

Range class

Encapsulates the object that represents a range of cells within a spreadsheet.

The Range type exposes the following members:

Properties

PropertyDescription
current_regionReturns a Range object that represents the current region.
The current region is a range bounded by any combination of blank rows and blank columns.
hyperlinksGets all hyperlink in the range.
row_countGets the count of rows in the range.
column_countGets the count of columns in the range.
nameGets or sets the name of the range.
refers_toGets the range’s refers to.
addressGets address of the range.
leftGets the distance, in points, from the left edge of column A to the left edge of the range.
topGets the distance, in points, from the top edge of row 1 to the top edge of the range.
widthGets the width of a range in points.
heightGets the width of a range in points.
first_rowGets the index of the first row of the range.
first_columnGets the index of the first column of the range.
valueGets and sets the value of the range.
column_widthSets or gets the column width of this range
row_heightSets or gets the height of rows in this range
entire_columnGets a Range object that represents the entire column (or columns) that contains the specified range.
entire_rowGets a Range object that represents the entire row (or rows) that contains the specified range.
worksheetGets the Range.worksheetobject which contains this range.

Methods

MethodDescription
auto_fillAutomaticall fill the target range.
auto_fillAutomaticall fill the target range.
set_styleApply the cell style.
set_styleSets the style of the range.
set_outline_bordersSets the outline borders around a range of cells with same border style and color.
set_outline_bordersSets the outline borders around a range of cells with same border style and color.
set_outline_bordersSets out line borders around a range of cells.
set_outline_borderSets outline border around a range of cells.
set_outline_borderSets outline border around a range of cells.
copyCopying the range with paste special options.
copyCopies data (including formulas), formatting, drawing objects etc. from a source range.
add_hyperlinkAdds a hyperlink to a specified cell or a range of cells.
get_enumeratorGets the enumerator for cells in this Range.
is_intersectIndicates whether the range is intersect.
intersectReturns a Range object that represents the rectangular intersection of two ranges.
union_rangReturns the union result of two ranges.
unionReturns the union of two ranges.
is_blankIndicates whether the range contains values.
mergeCombines a range of cells into a single cell.
un_mergeUnmerges merged cells of this range.
put_valuePuts a value into the range, if appropriate the value will be converted to other data type and cell’s number format will be reset.
apply_styleApplies formats for a whole range.
set_inside_bordersSet inside borders of the range.
move_toMove the current range to the dest range.
copy_dataCopies cell data (including formulas) from a source range.
copy_valueCopies cell value from a source range.
copy_styleCopies style settings from a source range.
get_cell_or_nullGets Cell object or null in this range.
get_offsetGets Range range by offset.

Remarks

The Range class denotes a region of Excel spreadsheet. With this, you can format and set value of the range. And you can simply copy range of Excel too.

Example

The following example shows how to create a range and set value the range of Excel.

from aspose.cells import Workbook

# Instantiating a Workbook object
workbook = Workbook()
#  Get the first Worksheet Cells.
cells = workbook.worksheets[0].cells
#  Create a range (A1:D3).
range = cells.create_range("A1", "D3")
#  Set value to the range.
range.value = "Hello"
# Save the Excel file
workbook.save("book1.xlsm")

See Also