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).

Return type:tuple(int, int)
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
comment

Returns the comment associated with this cell

Return type:openpyxl.comments.Comment
coordinate
data_type
encoding
guess_types

Return the hyperlink target or an empty string

internal_value

Always returns the value for excel.

is_date

Whether the value is formatted as a date

Return 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
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.

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