openpyxl.cell.cell module

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

Bases: openpyxl.styles.styleable.StyleableObject

Describes cell associated properties.

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

ERROR_CODES = ('#NULL!', '#DIV/0!', '#VALUE!', '#REF!', '#NAME?', '#NUM!', '#N/A')
TYPE_BOOL = 'b'
TYPE_ERROR = 'e'
TYPE_FORMULA = 'f'
TYPE_FORMULA_CACHE_STRING = 'str'
TYPE_INLINE = 'inlineStr'
TYPE_NULL = 'n'
TYPE_NUMERIC = 'n'
TYPE_STRING = 's'
VALID_TYPES = ('s', 'f', 'n', 'b', 'n', 'inlineStr', 'e', 'str')
anchor
returns the expected position of a cell in pixels from the top-left

of the sheet. For example, A1 anchor should be (0,0).

type:tuple(int, int)

Note

Deprecated: Use anchor objects for positioning

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

Column number of this cell (1-based)

column

The letter of this cell’s column (ex. ‘A’)

comment

Returns the comment associated with this cell

Type:openpyxl.comments.Comment
coordinate

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

data_type
encoding
guess_types

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)

set_explicit_value(value=None, data_type='s')[source]

Coerce values according to their explicit type

value

Get or set the value held in the cell.

Type:depends on the value (string, float, int or datetime.datetime)
openpyxl.cell.cell.WriteOnlyCell(ws=None, value=None)[source]