openpyxl.cell.cell module

Manage individual cells in a spreadsheet.

The Cell class is required to know its value and type, display options, and any other features of an Excel cell. Utilities for referencing cells using Excel’s ‘A1’ column/row nomenclature are also provided.

class openpyxl.cell.cell.Cell(worksheet, row=None, column=None, value=None, style_array=None)[source]

Bases: openpyxl.styles.styleable.StyleableObject

Describes cell associated properties.

Properties of interest include style, type, value, and address.

base_date
check_error(value)[source]

Tries to convert Error” else N/A

check_string(value)[source]

Check string coding, length, and line break character

col_idx

The numerical index of the column

column

Column number of this cell (1-based)

column_letter
comment

Returns the comment associated with this cell

Type:openpyxl.comments.Comment
coordinate

This cell’s coordinate (ex. ‘A5’)

data_type
encoding

Return the hyperlink target or an empty string

internal_value

Always returns the value for excel.

is_date

True if the value is formatted as a date

Type:bool
offset(row=0, column=0)[source]

Returns a cell location relative to this cell.

Parameters:
  • row (int) – number of rows to offset
  • column (int) – number of columns to offset
Return type:

openpyxl.cell.Cell

parent
row

Row number of this cell (1-based)

value

Get or set the value held in the cell.

Type:depends on the value (string, float, int or datetime.datetime)
class openpyxl.cell.cell.MergedCell(worksheet, row=None, column=None)[source]

Bases: openpyxl.styles.styleable.StyleableObject

Describes the properties of a cell in a merged cell and helps to display the borders of the merged cell.

The value of a MergedCell is always None.

column
comment = None
coordinate

This cell’s coordinate (ex. ‘A5’)

data_type = 'n'
row
value = None
openpyxl.cell.cell.WriteOnlyCell(ws=None, value=None)[source]
openpyxl.cell.cell.get_time_format(t)[source]
openpyxl.cell.cell.get_type(t, value)[source]