Row class

Row class

Represents a single row in a worksheet.

The Row type exposes the following members:

Properties

PropertyDescription
is_blankIndicates whether the row contains any data
is_collapsedwhether the row is collapsed
heightGets and sets the row height in unit of Points.
is_hiddenIndicates whether the row is hidden.
indexGets the index of this row.
group_levelGets the group level of the row.
is_height_matchedIndicates whether the row height matches current default font setting of the workbook.
True of this property also denotes the row height is “automatic” without custom height value set by user.
has_custom_styleIndicates whether this row has custom style settings(different from the default one inherited from workbook).
first_cellGets the first cell object in the row.
first_data_cellGets the first non-blank cell in the row.
last_cellGets the last cell object in the row.
last_data_cellGets the last non-blank cell in the row.

Gets the cell.

Indexer

NameDescription
[index]The column index

Methods

MethodDescription
get_cell_by_indexGet the cell by specific index in the cells collection of this row.
get_enumeratorGets an enumerator that iterates cells through this row.
get_cell_or_nullGets the cell or null in the specific index.
get_styleGets the style of this row.
set_styleSets the style of this row.
copy_settingsCopy settings of row, such as style, height, visibility, …etc.
apply_styleApplies formats for a whole row.
equalsChecks whether this object refers to the same row with another row object.

Example

from aspose.cells import BackgroundType, StyleFlag, Workbook
from aspose.pydrawing import Color

# Instantiating a Workbook object
workbook = Workbook()
# Obtaining the reference of the first worksheet
worksheet = workbook.worksheets[0]
style = workbook.create_style()
# Setting the background color to Blue
style.background_color = Color.blue
# Setting the foreground color to Red
style.foreground_color = Color.red
# setting Background Pattern
style.pattern = BackgroundType.DIAGONAL_STRIPE
# New Style Flag
styleFlag = StyleFlag()
# Set All Styles
styleFlag.all = True
# Get first row
row = worksheet.cells.rows[0]
# Apply Style to first row
row.apply_style(style, styleFlag)
# Saving the Excel file
workbook.save("book1.xls")

See Also