Paper Office
paper-xlsxAPI referenceworksheet.worksheet

Worksheet

paper-xlsx 0.2.1 API reference

Represents a worksheet.

Do not create worksheets yourself, use openpyxl.workbook.Workbook.create_sheet instead

Worksheet(parent, title=None)

Attributes

BREAK_COLUMN

attributeBREAK_COLUMN
= 2

BREAK_NONE

attributeBREAK_NONE
= 0

BREAK_ROW

attributeBREAK_ROW
= 1

HeaderFooter

attributeHeaderFooter
= HeaderFooter()

ORIENTATION_LANDSCAPE

attributeORIENTATION_LANDSCAPE
= 'landscape'

ORIENTATION_PORTRAIT

attributeORIENTATION_PORTRAIT
= 'portrait'

PAPERSIZE_A3

attributePAPERSIZE_A3
= '8'

PAPERSIZE_A4

attributePAPERSIZE_A4
= '9'

PAPERSIZE_A4_SMALL

attributePAPERSIZE_A4_SMALL
= '10'

PAPERSIZE_A5

attributePAPERSIZE_A5
= '11'

PAPERSIZE_EXECUTIVE

attributePAPERSIZE_EXECUTIVE
= '7'

PAPERSIZE_LEDGER

attributePAPERSIZE_LEDGER
= '4'
attributePAPERSIZE_LEGAL
= '5'

PAPERSIZE_LETTER

attributePAPERSIZE_LETTER
= '1'

PAPERSIZE_LETTER_SMALL

attributePAPERSIZE_LETTER_SMALL
= '2'

PAPERSIZE_STATEMENT

attributePAPERSIZE_STATEMENT
= '6'

PAPERSIZE_TABLOID

attributePAPERSIZE_TABLOID
= '3'

SHEETSTATE_HIDDEN

attributeSHEETSTATE_HIDDEN
= 'hidden'

SHEETSTATE_VERYHIDDEN

attributeSHEETSTATE_VERYHIDDEN
= 'veryHidden'

SHEETSTATE_VISIBLE

attributeSHEETSTATE_VISIBLE
= 'visible'

active_cell

attributeactive_cell

array_formulae

attributearray_formulae

Returns a dictionary of cells with array formulae and the cells in array

column_groups

attributecolumn_groups

Return a list of column ranges where more than one column

columns

attributecolumns

Produces all cells in the worksheet, by column (see iter_cols)

dimensions

attributedimensions

Returns the result of calculate_dimension

encoding

attributeencoding

evenFooter

attributeevenFooter

evenHeader

attributeevenHeader

firstFooter

attributefirstFooter

firstHeader

attributefirstHeader

freeze_panes

attributefreeze_panes

max_column

attributemax_column

The maximum column index containing data (1-based)

:type: int

max_row

attributemax_row

The maximum row index containing data (1-based)

:type: int

merged_cell_ranges

attributemerged_cell_ranges

Return a copy of cell ranges

mime_type

attributemime_type
= 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'

min_column

attributemin_column

The minimum column index containing data (1-based)

:type: int

min_row

attributemin_row

The minimum row index containing data (1-based)

:type: int

oddFooter

attributeoddFooter

oddHeader

attributeoddHeader

parent

attributeparent

path

attributepath
attributeprint_area

The print area for the worksheet, or None if not set. To set, supply a range like 'A1:D4' or a list of ranges.

attributeprint_title_cols

Columns to be printed at the left side of every page (ex: 'A:C')

attributeprint_title_rows

Rows to be printed at the top of every page (ex: '1:3')

attributeprint_titles

rows

attributerows

Produces all cells in the worksheet, by row (see iter_rows)

:type: generator

selected_cell

attributeselected_cell

sheet_view

attributesheet_view

show_gridlines

attributeshow_gridlines

tables

attributetables

title

attributetitle

values

attributevalues

Produces all cell values in the worksheet, by row

:type: generator

Functions

__delitem__

func__delitem__(key)
paramkey

__getitem__

func__getitem__(key)

Convenience access by Excel style coordinates

The key can be a single cell coordinate 'A1', a range of cells 'A1:D25', individual rows or columns 'A', 4 or ranges of rows or columns 'A:D', 4:10.

Single cells will always be created if they do not exist.

Returns either a single cell or a tuple of rows or columns.

paramkey

__iter__

func__iter__()

__setitem__

func__setitem__(key, value)
paramkey
paramvalue

add_chart

funcadd_chart(chart, anchor=None)

Add a chart to the sheet Optionally provide a cell for the top-left anchor

paramchart
paramanchor
= None

add_data_validation

funcadd_data_validation(data_validation)

Add a data-validation object to the sheet. The data-validation object defines the type of data-validation to be applied and the cell or range of cells it should apply to.

paramdata_validation

add_image

funcadd_image(img, anchor=None)

Add an image to the sheet. Optionally provide a cell for the top-left anchor

paramimg
paramanchor
= None

add_pivot

funcadd_pivot(pivot)
parampivot

add_table

funcadd_table(table)

Check for duplicate name in definedNames and other worksheet tables before adding table.

paramtable

allowed_values

funcallowed_values(cell)

The data-validation vocabulary for cell (address string or Cell), or None when no list-type validation covers it (paper-xlsx).

paramcell

append

funcappend(iterable)
paramiterable

append_table_row

funcappend_table_row(table_name, values)

Append one row to a supported named table atomically.

paramtable_namestr

Name of the table to expand.

paramvaluesiterable | mapping

Row values as a sequence or column-name mapping.

Returns

None

None.

calculate_dimension

funccalculate_dimension()

Return the minimum bounding range for all cells containing data (ex. 'A1:M24')

:rtype: string

cell

funccell(row, column, value=None)

Returns a cell object based on the given coordinates.

Usage: cell(row=15, column=1, value=5)

Calling cell creates cells in memory when they are first accessed.

paramrowint

row index of the cell (e.g. 4)

paramcolumnint

column index of the cell (e.g. 3)

paramvaluenumeric, ``datetime.time``, string, bool, | none
= None

value of the cell (e.g. 5)

delete_cols

funcdelete_cols(idx, amount=1)

Delete column or columns from col==idx

Under preserve=True on a loaded sheet, references into the shifted range are rewritten and an AddressRemap is returned; a delete that would strand a reference refuses with UnsupportedStructureError and changes nothing. Stock loads and added sheets keep upstream behaviour and return None.

paramidx
paramamount
= 1

delete_rows

funcdelete_rows(idx, amount=1)

Delete row or rows from row==idx

Under preserve=True on a loaded sheet, references into the shifted range are rewritten and an AddressRemap is returned; a delete that would strand a reference (or drop cells a chart or name still points at) refuses with UnsupportedStructureError and changes nothing. Stock loads and added sheets keep upstream behaviour and return None.

paramidx
paramamount
= 1

insert_cols

funcinsert_cols(idx, amount=1)

Insert column or columns before col==idx

Under preserve=True on a loaded sheet, references into the shifted range are rewritten and an AddressRemap is returned; a shift that would strand a reference refuses with UnsupportedStructureError and changes nothing. Stock loads and added sheets keep upstream behaviour and return None.

paramidx
paramamount
= 1

insert_rows

funcinsert_rows(idx, amount=1)

Insert row or rows before row==idx

Under preserve=True on a loaded sheet the fork rewrites every reference that points into the shifted range (formulas, defined names, chart series) and returns an AddressRemap so pre-edit addresses can be remapped; a shift that would strand a reference it cannot rewrite refuses with UnsupportedStructureError and changes nothing. Stock loads and in-session-added sheets keep the upstream behaviour — references are NOT updated — and return None.

paramidx
paramamount
= 1

iter_cols

funciter_cols(min_col=None, max_col=None, min_row=None, max_row=None, values_only=False)

Produces cells from the worksheet, by column. Specify the iteration range using indices of rows and columns.

If no indices are specified the range starts at A1.

If no cells are in the worksheet an empty tuple will be returned.

parammin_colint
= None

smallest column index (1-based index)

parammax_colint
= None

largest column index (1-based index)

parammin_rowint
= None

smallest row index (1-based index)

parammax_rowint
= None

largest row index (1-based index)

paramvalues_onlybool
= False

whether only cell values should be returned

iter_rows

funciter_rows(min_row=None, max_row=None, min_col=None, max_col=None, values_only=False)

Produces cells from the worksheet, by row. Specify the iteration range using indices of rows and columns.

If no indices are specified the range starts at A1.

If no cells are in the worksheet an empty tuple will be returned.

parammin_rowint
= None

smallest row index (1-based index)

parammax_rowint
= None

largest row index (1-based index)

parammin_colint
= None

smallest column index (1-based index)

parammax_colint
= None

largest column index (1-based index)

paramvalues_onlybool
= False

whether only cell values should be returned

merge_cells

funcmerge_cells(range_string=None, start_row=None, start_column=None, end_row=None, end_column=None)

Set merge on a cell range. Range is a cell range (e.g. A1:E1)

paramrange_string
= None
paramstart_row
= None
paramstart_column
= None
paramend_row
= None
paramend_column
= None

move_range

funcmove_range(cell_range, rows=0, cols=0, translate=False)

Move a cell range by the number of rows and/or columns: down if rows > 0 and up if rows < 0 right if cols > 0 and left if cols < 0 Existing cells will be overwritten. Formulae and references will not be updated.

Under preserve=True the move lands as tracked cell edits and refuses with UnsupportedStructureError (changing nothing) when it cannot keep the sheet coherent — e.g. merged ranges, tables, conditional formatting or data validation intersecting either rectangle, or outside formulas that reference the moved block.

paramcell_range
paramrows
= 0
paramcols
= 0
paramtranslate
= False

replace_image

funcreplace_image(target, replacement, *, name=None)

Replace one loaded image while preserving its drawing anchor.

paramtargetopenpyxl.drawing.image.Image | str

Loaded image or its anchor coordinate.

paramreplacementopenpyxl.drawing.image.Image | path - like

Replacement image or image source.

paramnamestr | None
= None

Optional image name used to resolve an ambiguous anchor.

Returns

openpyxl.drawing.image.Image

The loaded image selected for replacement.

set_printer_settings

funcset_printer_settings(paper_size, orientation)

Set printer settings

parampaper_size
paramorientation

unmerge_cells

funcunmerge_cells(range_string=None, start_row=None, start_column=None, end_row=None, end_column=None)

Remove merge on a cell range. Range is a cell range (e.g. A1:E1)

paramrange_string
= None
paramstart_row
= None
paramstart_column
= None
paramend_row
= None
paramend_column
= None

On this page