openpyxl - A Python library to read/write Excel 2010 xlsx/xlsm files

Author:Eric Gazoni, Charlie Clark
Source code:https://foss.heptapod.net/openpyxl/openpyxl
Issues:https://foss.heptapod.net/openpyxl/openpyxl/-/issues
Generated:Mar 11, 2023
License:MIT/Expat
Version:3.1.2
coverage status

Introduction

openpyxl is a Python library to read/write Excel 2010 xlsx/xlsm/xltx/xltm files.

It was born from lack of existing library to read/write natively from Python the Office Open XML format.

All kudos to the PHPExcel team as openpyxl was initially based on PHPExcel.

Security

By default openpyxl does not guard against quadratic blowup or billion laughs xml attacks. To guard against these attacks install defusedxml.

Mailing List

The user list can be found on http://groups.google.com/group/openpyxl-users

Sample code:

from openpyxl import Workbook
wb = Workbook()

# grab the active worksheet
ws = wb.active

# Data can be assigned directly to cells
ws['A1'] = 42

# Rows can also be appended
ws.append([1, 2, 3])

# Python types will automatically be converted
import datetime
ws['A2'] = datetime.datetime.now()

# Save the file
wb.save("sample.xlsx")

Documentation

The documentation is at: https://openpyxl.readthedocs.io

  • installation methods
  • code examples
  • instructions for contributing

Release notes: https://openpyxl.readthedocs.io/en/stable/changes.html

Support

This is an open source project, maintained by volunteers in their spare time. This may well mean that particular features or functions that you would like are missing. But things don’t have to stay that way. You can contribute the project Development yourself or contract a developer for particular features.

Professional support for openpyxl is available from Clark Consulting & Research and Adimian. Donations to the project to support further development and maintenance are welcome.

Bug reports and feature requests should be submitted using the issue tracker. Please provide a full traceback of any error you see and if possible a sample file. If for reasons of confidentiality you are unable to make a file publicly available then contact of one the developers.

The repository is being provided by Octobus and Clever Cloud.

How to Contribute

Any help will be greatly appreciated, just follow those steps:

1. Please join the group and create a branch (https://foss.heptapod.net/openpyxl/openpyxl/) and follow the Merge Request Start Guide. for each independent feature, don’t try to fix all problems at the same time, it’s easier for those who will review and merge your changes ;-)

2. Hack hack hack

3. Don’t forget to add unit tests for your changes! (YES, even if it’s a one-liner, changes without tests will not be accepted.) There are plenty of examples in the source if you lack know-how or inspiration.

4. If you added a whole new feature, or just improved something, you can be proud of it, so add yourself to the AUTHORS file :-)

5. Let people know about the shiny thing you just implemented, update the docs!

6. When it’s done, just issue a pull request (click on the large “pull request” button on your repository) and wait for your code to be reviewed, and, if you followed all theses steps, merged into the main repository.

For further information see Development

Other ways to help

There are several ways to contribute, even if you can’t code (or can’t code well):

  • triaging bugs on the bug tracker: closing bugs that have already been closed, are not relevant, cannot be reproduced, …
  • updating documentation in virtually every area: many large features have been added (mainly about charts and images at the moment) but without any documentation, it’s pretty hard to do anything with it
  • proposing compatibility fixes for different versions of Python: we support 3.6, 3.7, 3.8 and 3.9.

Tutorial

Installation

Install openpyxl using pip. It is advisable to do this in a Python virtualenv without system packages:

$ pip install openpyxl

Note

There is support for the popular lxml library which will be used if it is installed. This is particular useful when creating large files.

Warning

To be able to include images (jpeg, png, bmp,…) into an openpyxl file, you will also need the “pillow” library that can be installed with:

$ pip install pillow

or browse https://pypi.python.org/pypi/Pillow/, pick the latest version and head to the bottom of the page for Windows binaries.

Working with a checkout

Sometimes you might want to work with the checkout of a particular version. This may be the case if bugs have been fixed but a release has not yet been made.

$ pip install -e hg+https://foss.heptapod.net/openpyxl/openpyxl/@3.1#egg=openpyxl
Create a workbook

There is no need to create a file on the filesystem to get started with openpyxl. Just import the Workbook class and start work:

>>> from openpyxl import Workbook
>>> wb = Workbook()

A workbook is always created with at least one worksheet. You can get it by using the Workbook.active property:

>>> ws = wb.active

Note

This is set to 0 by default. Unless you modify its value, you will always get the first worksheet by using this method.

You can create new worksheets using the Workbook.create_sheet() method:

>>> ws1 = wb.create_sheet("Mysheet") # insert at the end (default)
# or
>>> ws2 = wb.create_sheet("Mysheet", 0) # insert at first position
# or
>>> ws3 = wb.create_sheet("Mysheet", -1) # insert at the penultimate position

Sheets are given a name automatically when they are created. They are numbered in sequence (Sheet, Sheet1, Sheet2, …). You can change this name at any time with the Worksheet.title property:

ws.title = "New Title"

Once you gave a worksheet a name, you can get it as a key of the workbook:

>>> ws3 = wb["New Title"]

You can review the names of all worksheets of the workbook with the Workbook.sheetname attribute

>>> print(wb.sheetnames)
['Sheet2', 'New Title', 'Sheet1']

You can loop through worksheets

>>> for sheet in wb:
...     print(sheet.title)

You can create copies of worksheets within a single workbook:

Workbook.copy_worksheet() method:

>>> source = wb.active
>>> target = wb.copy_worksheet(source)

Note

Only cells (including values, styles, hyperlinks and comments) and certain worksheet attributes (including dimensions, format and properties) are copied. All other workbook / worksheet attributes are not copied - e.g. Images, Charts.

You also cannot copy worksheets between workbooks. You cannot copy a worksheet if the workbook is open in read-only or write-only mode.

Playing with data
Accessing one cell

Now we know how to get a worksheet, we can start modifying cells content. Cells can be accessed directly as keys of the worksheet:

>>> c = ws['A4']

This will return the cell at A4, or create one if it does not exist yet. Values can be directly assigned:

>>> ws['A4'] = 4

There is also the Worksheet.cell() method.

This provides access to cells using row and column notation:

>>> d = ws.cell(row=4, column=2, value=10)

Note

When a worksheet is created in memory, it contains no cells. They are created when first accessed.

Warning

Because of this feature, scrolling through cells instead of accessing them directly will create them all in memory, even if you don’t assign them a value.

Something like

>>> for x in range(1,101):
...        for y in range(1,101):
...            ws.cell(row=x, column=y)

will create 100x100 cells in memory, for nothing.

Accessing many cells

Ranges of cells can be accessed using slicing:

>>> cell_range = ws['A1':'C2']

Ranges of rows or columns can be obtained similarly:

>>> colC = ws['C']
>>> col_range = ws['C:D']
>>> row10 = ws[10]
>>> row_range = ws[5:10]

You can also use the Worksheet.iter_rows() method:

>>> for row in ws.iter_rows(min_row=1, max_col=3, max_row=2):
...    for cell in row:
...        print(cell)
<Cell Sheet1.A1>
<Cell Sheet1.B1>
<Cell Sheet1.C1>
<Cell Sheet1.A2>
<Cell Sheet1.B2>
<Cell Sheet1.C2>

Likewise the Worksheet.iter_cols() method will return columns:

>>> for col in ws.iter_cols(min_row=1, max_col=3, max_row=2):
...     for cell in col:
...         print(cell)
<Cell Sheet1.A1>
<Cell Sheet1.A2>
<Cell Sheet1.B1>
<Cell Sheet1.B2>
<Cell Sheet1.C1>
<Cell Sheet1.C2>

Note

For performance reasons the Worksheet.iter_cols() method is not available in read-only mode.

If you need to iterate through all the rows or columns of a file, you can instead use the Worksheet.rows property:

>>> ws = wb.active
>>> ws['C9'] = 'hello world'
>>> tuple(ws.rows)
((<Cell Sheet.A1>, <Cell Sheet.B1>, <Cell Sheet.C1>),
(<Cell Sheet.A2>, <Cell Sheet.B2>, <Cell Sheet.C2>),
(<Cell Sheet.A3>, <Cell Sheet.B3>, <Cell Sheet.C3>),
(<Cell Sheet.A4>, <Cell Sheet.B4>, <Cell Sheet.C4>),
(<Cell Sheet.A5>, <Cell Sheet.B5>, <Cell Sheet.C5>),
(<Cell Sheet.A6>, <Cell Sheet.B6>, <Cell Sheet.C6>),
(<Cell Sheet.A7>, <Cell Sheet.B7>, <Cell Sheet.C7>),
(<Cell Sheet.A8>, <Cell Sheet.B8>, <Cell Sheet.C8>),
(<Cell Sheet.A9>, <Cell Sheet.B9>, <Cell Sheet.C9>))

or the Worksheet.columns property:

>>> tuple(ws.columns)
((<Cell Sheet.A1>,
<Cell Sheet.A2>,
<Cell Sheet.A3>,
<Cell Sheet.A4>,
<Cell Sheet.A5>,
<Cell Sheet.A6>,
...
<Cell Sheet.B7>,
<Cell Sheet.B8>,
<Cell Sheet.B9>),
(<Cell Sheet.C1>,
<Cell Sheet.C2>,
<Cell Sheet.C3>,
<Cell Sheet.C4>,
<Cell Sheet.C5>,
<Cell Sheet.C6>,
<Cell Sheet.C7>,
<Cell Sheet.C8>,
<Cell Sheet.C9>))

Note

For performance reasons the Worksheet.columns property is not available in read-only mode.

Values only

If you just want the values from a worksheet you can use the Worksheet.values property. This iterates over all the rows in a worksheet but returns just the cell values:

for row in ws.values:
   for value in row:
     print(value)

Both Worksheet.iter_rows() and Worksheet.iter_cols() can take the values_only parameter to return just the cell’s value:

>>> for row in ws.iter_rows(min_row=1, max_col=3, max_row=2, values_only=True):
...   print(row)

(None, None, None)
(None, None, None)
Data storage

Once we have a Cell, we can assign it a value:

>>> c.value = 'hello, world'
>>> print(c.value)
'hello, world'

>>> d.value = 3.14
>>> print(d.value)
3.14
Saving to a file

The simplest and safest way to save a workbook is by using the Workbook.save() method of the Workbook object:

>>> wb = Workbook()
>>> wb.save('balances.xlsx')

Warning

This operation will overwrite existing files without warning.

Note

The filename extension is not forced to be xlsx or xlsm, although you might have some trouble opening it directly with another application if you don’t use an official extension.

As OOXML files are basically ZIP files, you can also open it with your favourite ZIP archive manager.

If required, you can specify the attribute wb.template=True, to save a workbook as a template:

>>> wb = load_workbook('document.xlsx')
>>> wb.template = True
>>> wb.save('document_template.xltx')
Saving as a stream

If you want to save the file to a stream, e.g. when using a web application such as Pyramid, Flask or Django then you can simply provide a NamedTemporaryFile():

>>> from tempfile import NamedTemporaryFile
>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> with NamedTemporaryFile() as tmp:
        wb.save(tmp.name)
        tmp.seek(0)
        stream = tmp.read()

Warning

You should monitor the data attributes and document extensions for saving documents in the document templates and vice versa, otherwise the result table engine can not open the document.

Note

The following will fail:

>>> wb = load_workbook('document.xlsx')
>>> # Need to save with the extension *.xlsx
>>> wb.save('new_document.xlsm')
>>> # MS Excel can't open the document
>>>
>>> # or
>>>
>>> # Need specify attribute keep_vba=True
>>> wb = load_workbook('document.xlsm')
>>> wb.save('new_document.xlsm')
>>> # MS Excel will not open the document
>>>
>>> # or
>>>
>>> wb = load_workbook('document.xltm', keep_vba=True)
>>> # If we need a template document, then we must specify extension as *.xltm.
>>> wb.save('new_document.xlsm')
>>> # MS Excel will not open the document
Loading from a file

You can use the openpyxl.load_workbook() to open an existing workbook:

>>> from openpyxl import load_workbook
>>> wb = load_workbook(filename = 'empty_book.xlsx')
>>> sheet_ranges = wb['range names']
>>> print(sheet_ranges['D18'].value)
3

Note

There are several flags that can be used in load_workbook.

  • data_only controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet.
  • keep_vba controls whether any Visual Basic elements are preserved or not (default). If they are preserved they are still not editable.

Warning

openpyxl does currently not read all possible items in an Excel file so shapes will be lost from existing files if they are opened and saved with the same name.

Errors loading workbooks

Sometimes openpyxl will fail to open a workbook. This is usually because there is something wrong with the file. If this is the case then openpyxl will try and provide some more information. Openpyxl follows the OOXML specification closely and will reject files that do not because they are invalid. When this happens you can use the exception from openpyxl to inform the developers of whichever application or library produced the file. As the OOXML specification is publicly available it is important that developers follow it.

You can find the spec by searching for ECMA-376, most of the implementation specifics are in Part 4.

This ends the tutorial for now, you can proceed to the Simple usage section

Simple usage

Example: Creating a simple spreadsheet and bar chart

In this example we’re going to create a sheet from scratch and add some data and then plot it. We’ll also explore some limited cell style and formatting.

The data we’ll be entering on the sheet is below:

Species Leaf Color Height (cm)
Maple Red 549
Oak Green 783
Pine Green 1204

To start, let’s load in openpyxl and create a new workbook. and get the active sheet. We’ll also enter our tree data.

>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>> treeData = [["Type", "Leaf Color", "Height"], ["Maple", "Red", 549], ["Oak", "Green", 783], ["Pine", "Green", 1204]]

Next we’ll enter this data onto the worksheet. As this is a list of lists, we can simply use the Worksheet.append() function.

>>> for row in treeData:
...     ws.append(row)

Now we should make our heading Bold to make it stand out a bit more, to do that we’ll need to create a styles.Font and apply it to all the cells in our header row.

>>> from openpyxl.styles import Font
>>> ft = Font(bold=True)
>>> for row in ws["A1:C1"]:
...     for cell in row:
...         cell.font = ft

It’s time to make some charts. First, we’ll start by importing the appropriate packages from openpyxl.chart then define some basic attributes

>>> from openpyxl.chart import BarChart, Series, Reference
>>> chart = BarChart()
>>> chart.type = "col"
>>> chart.title = "Tree Height"
>>> chart.y_axis.title = 'Height (cm)'
>>> chart.x_axis.title = 'Tree Type'
>>> chart.legend = None

That’s created the skeleton of what will be our bar chart. Now we need to add references to where the data is and pass that to the chart object

>>> data = Reference(ws, min_col=3, min_row=2, max_row=4, max_col=3)
>>> categories = Reference(ws, min_col=1, min_row=2, max_row=4, max_col=1)
>>> chart.add_data(data)
>>> chart.set_categories(categories)

Finally we can add it to the sheet.

>>> ws.add_chart(chart, "E1")
>>> wb.save("TreeData.xlsx")

And there you have it. If you open that doc now it should look something like this

_images/exercise-1-result.png

Working with styles

Introduction

Styles are used to change the look of your data while displayed on screen. They are also used to determine the formatting for numbers.

Styles can be applied to the following aspects:

  • font to set font size, color, underlining, etc.
  • fill to set a pattern or color gradient
  • border to set borders on a cell
  • cell alignment
  • protection

The following are the default values

>>> from openpyxl.styles import PatternFill, Border, Side, Alignment, Protection, Font
>>> font = Font(name='Calibri',
...                 size=11,
...                 bold=False,
...                 italic=False,
...                 vertAlign=None,
...                 underline='none',
...                 strike=False,
...                 color='FF000000')
>>> fill = PatternFill(fill_type=None,
...                 start_color='FFFFFFFF',
...                 end_color='FF000000')
>>> border = Border(left=Side(border_style=None,
...                           color='FF000000'),
...                 right=Side(border_style=None,
...                            color='FF000000'),
...                 top=Side(border_style=None,
...                          color='FF000000'),
...                 bottom=Side(border_style=None,
...                             color='FF000000'),
...                 diagonal=Side(border_style=None,
...                               color='FF000000'),
...                 diagonal_direction=0,
...                 outline=Side(border_style=None,
...                              color='FF000000'),
...                 vertical=Side(border_style=None,
...                               color='FF000000'),
...                 horizontal=Side(border_style=None,
...                                color='FF000000')
...                )
>>> alignment=Alignment(horizontal='general',
...                     vertical='bottom',
...                     text_rotation=0,
...                     wrap_text=False,
...                     shrink_to_fit=False,
...                     indent=0)
>>> number_format = 'General'
>>> protection = Protection(locked=True,
...                         hidden=False)
>>>
Cell Styles and Named Styles

There are two types of styles: cell styles and named styles, also known as style templates.

Cell Styles

Cell styles are shared between objects and once they have been assigned they cannot be changed. This stops unwanted side-effects such as changing the style for lots of cells when only one changes.

>>> from openpyxl.styles import colors
>>> from openpyxl.styles import Font, Color
>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> a1 = ws['A1']
>>> d4 = ws['D4']
>>> ft = Font(color="FF0000")
>>> a1.font = ft
>>> d4.font = ft
>>>
>>> a1.font.italic = True # is not allowed # doctest: +SKIP
>>>
>>> # If you want to change the color of a Font, you need to reassign it::
>>>
>>> a1.font = Font(color="FF0000", italic=True) # the change only affects A1
Copying styles

Styles can also be copied

>>> from openpyxl.styles import Font
>>> from copy import copy
>>>
>>> ft1 = Font(name='Arial', size=14)
>>> ft2 = copy(ft1)
>>> ft2.name = "Tahoma"
>>> ft1.name
'Arial'
>>> ft2.name
'Tahoma'
>>> ft2.size # copied from the
14.0
Colours

Colours for fonts, backgrounds, borders, etc. can be set in three ways: indexed, aRGB or theme. Indexed colours are the legacy implementation and the colours themselves depend upon the index provided with the workbook or with the application default. Theme colours are useful for complementary shades of colours but also depend upon the theme being present in the workbook. It is, therefore, advisable to use aRGB colours.

aRGB colours

RGB colours are set using hexadecimal values for red, green and blue.

>>> from openpyxl.styles import Font
>>> font = Font(color="FF0000")

The alpha value refers in theory to the transparency of the colour but this is not relevant for cell styles. The default of 00 will prepended to any simple RGB value:

>>> from openpyxl.styles import Font
>>> font = Font(color="00FF00")
>>> font.color.rgb
'0000FF00'

There is also support for legacy indexed colours as well as themes and tints.

>>> from openpyxl.styles.colors import Color
>>> c = Color(indexed=32)
>>> c = Color(theme=6, tint=0.5)
Indexed Colours
Standard Colours
Index
0-4 00000000 00FFFFFF 00FF0000 0000FF00 000000FF
5-9 00FFFF00 00FF00FF 0000FFFF 00000000 00FFFFFF
10-14 00FF0000 0000FF00 000000FF 00FFFF00 00FF00FF
15-19 0000FFFF 00800000 00008000 00000080 00808000
20-24 00800080 00008080 00C0C0C0 00808080 009999FF
25-29 00993366 00FFFFCC 00CCFFFF 00660066 00FF8080
30-34 000066CC 00CCCCFF 00000080 00FF00FF 00FFFF00
35-39 0000FFFF 00800080 00800000 00008080 000000FF
40-44 0000CCFF 00CCFFFF 00CCFFCC 00FFFF99 0099CCFF
45-49 00FF99CC 00CC99FF 00FFCC99 003366FF 0033CCCC
50-54 0099CC00 00FFCC00 00FF9900 00FF6600 00666699
55-60 00969696 00003366 00339966 00003300 00333300
60-63 00993300 00993366 00333399 00333333

The indices 64 and 65 cannot be set and are reserved for the system foreground and background colours respectively.

Applying Styles

Styles are applied directly to cells

>>> from openpyxl.workbook import Workbook
>>> from openpyxl.styles import Font, Fill
>>> wb = Workbook()
>>> ws = wb.active
>>> c = ws['A1']
>>> c.font = Font(size=12)

Styles can also applied to columns and rows but note that this applies only to cells created (in Excel) after the file is closed. If you want to apply styles to entire rows and columns then you must apply the style to each cell yourself. This is a restriction of the file format:

>>> col = ws.column_dimensions['A']
>>> col.font = Font(bold=True)
>>> row = ws.row_dimensions[1]
>>> row.font = Font(underline="single")
Styling Merged Cells

The merged cell behaves similarly to other cell objects. Its value and format is defined in its top-left cell. In order to change the border of the whole merged cell, change the border of its top-left cell. The formatting is generated for the purpose of writing.

>>> from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
>>> from openpyxl import Workbook
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>> ws.merge_cells('B2:F4')
>>>
>>> top_left_cell = ws['B2']
>>> top_left_cell.value = "My Cell"
>>>
>>> thin = Side(border_style="thin", color="000000")
>>> double = Side(border_style="double", color="ff0000")
>>>
>>> top_left_cell.border = Border(top=double, left=thin, right=thin, bottom=double)
>>> top_left_cell.fill = PatternFill("solid", fgColor="DDDDDD")
>>> top_left_cell.fill = fill = GradientFill(stop=("000000", "FFFFFF"))
>>> top_left_cell.font  = Font(b=True, color="FF0000")
>>> top_left_cell.alignment = Alignment(horizontal="center", vertical="center")
>>>
>>> wb.save("styled.xlsx")
Using number formats

You can specify the number format for cells, or for some instances (ie datetime) it will automatically format.

>>> import datetime
>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>> # set date using a Python datetime
>>> ws['A1'] = datetime.datetime(2010, 7, 21)
>>>
>>> ws['A1'].number_format
'yyyy-mm-dd h:mm:ss'
>>>
>>> ws["A2"] = 0.123456
>>> ws["A2"].number_format = "0.00" # Display to 2dp
Edit Page Setup
>>> from openpyxl.workbook import Workbook
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> ws.page_setup.orientation = ws.ORIENTATION_LANDSCAPE
>>> ws.page_setup.paperSize = ws.PAPERSIZE_TABLOID
>>> ws.page_setup.fitToHeight = 0
>>> ws.page_setup.fitToWidth = 1
Named Styles

In contrast to Cell Styles, Named Styles are mutable. They make sense when you want to apply formatting to lots of different cells at once. NB. once you have assigned a named style to a cell, additional changes to the style will not affect the cell.

Once a named style has been registered with a workbook, it can be referred to simply by name.

Creating a Named Style
>>> from openpyxl.styles import NamedStyle, Font, Border, Side
>>> highlight = NamedStyle(name="highlight")
>>> highlight.font = Font(bold=True, size=20)
>>> bd = Side(style='thick', color="000000")
>>> highlight.border = Border(left=bd, top=bd, right=bd, bottom=bd)

Once a named style has been created, it can be registered with the workbook:

>>> wb.add_named_style(highlight)

But named styles will also be registered automatically the first time they are assigned to a cell:

>>> ws['A1'].style = highlight

Once registered, assign the style using just the name:

>>> ws['D5'].style = 'highlight'
Using builtin styles

The specification includes some builtin styles which can also be used. Unfortunately, the names for these styles are stored in their localised forms. openpyxl will only recognise the English names and only exactly as written here. These are as follows:

  • ‘Normal’ # same as no style
Number formats
  • ‘Comma’
  • ‘Comma [0]’
  • ‘Currency’
  • ‘Currency [0]’
  • ‘Percent’
Informative
  • ‘Calculation’
  • ‘Total’
  • ‘Note’
  • ‘Warning Text’
  • ‘Explanatory Text’
Text styles
  • ‘Title’
  • ‘Headline 1’
  • ‘Headline 2’
  • ‘Headline 3’
  • ‘Headline 4’
  • ‘Hyperlink’
  • ‘Followed Hyperlink’
  • ‘Linked Cell’
Comparisons
  • ‘Input’
  • ‘Output’
  • ‘Check Cell’
  • ‘Good’
  • ‘Bad’
  • ‘Neutral’
Highlights
  • ‘Accent1’
  • ‘20 % - Accent1’
  • ‘40 % - Accent1’
  • ‘60 % - Accent1’
  • ‘Accent2’
  • ‘20 % - Accent2’
  • ‘40 % - Accent2’
  • ‘60 % - Accent2’
  • ‘Accent3’
  • ‘20 % - Accent3’
  • ‘40 % - Accent3’
  • ‘60 % - Accent3’
  • ‘Accent4’
  • ‘20 % - Accent4’
  • ‘40 % - Accent4’
  • ‘60 % - Accent4’
  • ‘Accent5’
  • ‘20 % - Accent5’
  • ‘40 % - Accent5’
  • ‘60 % - Accent5’
  • ‘Accent6’
  • ‘20 % - Accent6’
  • ‘40 % - Accent6’
  • ‘60 % - Accent6’
  • ‘Pandas’

For more information about the builtin styles please refer to the openpyxl.styles.builtins

Working with Rich Text

Introduction

Normally styles apply to everything in an individual cell. However, Rich Text allows formatting of parts of the text in a string.

Rich Text objects can contain a mix of unformatted text and TextBlock objects that contains an InlineFont style and a the text which is to be formatted like this. The result is a CellRichText object.

>>> from openpyxl.cell.text import InlineFont
>>> from openpyxl.cell.rich_text import TextBlock, CellRichText
>>> rich_string1 = CellRichText(
...    'This is a test ',
...    TextBlock(InlineFont(b=True), 'xxx'),
...   'yyy'
... )

InlineFont objects are virtually identical to the Font objects, but use a different attribute name, rFont, for the name of the font. Unfortunately, this is required by OOXML and cannot be avoided.

>>> inline_font = InlineFont(rFont='Calibri', # Font name
...                          sz=22,           # in 1/144 in. (1/2 point) units, must be integer
...                          charset=None,    # character set (0 to 255), less required with UTF-8
...                          family=None,     # Font family
...                          b=True,          # Bold (True/False)
...                          i=None,          # Italics (True/False)
...                          strike=None,     # strikethrough
...                          outline=None,
...                          shadow=None,
...                          condense=None,
...                          extend=None,
...                          color=None,
...                          u=None,
...                          vertAlign=None,
...                          scheme=None,
...                          )

Fortunately, if you already have a Font object, you can simply initialize an InlineFont object with an existing Font object:

>>> from openpyxl.cell.text import Font
>>> font = Font(name='Calibri',
...             size=11,
...             bold=False,
...             italic=False,
...             vertAlign=None,
...             underline='none',
...             strike=False,
...             color='00FF0000')
>>> inline_font = InlineFont(font)

You can create InlineFont objects on their own, and use them later. This makes working with Rich Text cleaner and easier:

>>> big = InlineFont(sz="30.0")
>>> medium = InlineFont(sz="20.0")
>>> small = InlineFont(sz="10.0")
>>> bold = InlineFont(b=True)
>>> b = TextBlock
>>> rich_string2 = CellRichText(
...       b(big, 'M'),
...       b(medium, 'i'),
...       b(small, 'x'),
...       b(medium, 'e'),
...       b(big, 'd')
... )

For example:

>>> red = InlineFont(color='FF000000')
>>> rich_string1 = CellRichText(['When the color ', TextBlock(red, 'red'), ' is used, you can expect ', TextBlock(red, 'danger')])

The CellRichText object is derived from list, and can be used as such.

Whitespace

CellRichText objects do not add whitespace between elements when rendering them as strings or saving files.

>>> t = CellRichText()
>>> t.append('xx')
>>> t.append(TextBlock(red, "red"))

You can also cast it to a str to get only the text, without formatting.

>>> str(t)
'xxred'
Editing Rich Text

As editing large blocks of text with formatting can be tricky, the as_list() method returns a list of strings to make indexing easy.

>>> l = rich_string1.as_list()
>>> l
['When the color ', 'red', ' is used, you can expect ', 'danger']
>>> l.index("danger")
3
>>> rich_string1[3].text = "fun"
>>> str(rich_string1)
'When the color red is used, you can expect fun'
Rich Text assignment to cells

Rich Text objects can be assigned directly to cells

>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>> ws['A1'] = rich_string1
>>> ws['A2'] = 'Simple string'

Conditional Formatting

Excel supports three different types of conditional formatting: builtins, standard and custom. Builtins combine specific rules with predefined styles. Standard conditional formats combine specific rules with custom formatting. In additional it is possible to define custom formulae for applying custom formats using differential styles.

Note

The syntax for the different rules varies so much that it is not possible for openpyxl to know whether a rule makes sense or not.

The basic syntax for creating a formatting rule is:

>>> from openpyxl.formatting import Rule
>>> from openpyxl.styles import Font, PatternFill, Border
>>> from openpyxl.styles.differential import DifferentialStyle
>>> dxf = DifferentialStyle(font=Font(bold=True), fill=PatternFill(start_color='EE1111', end_color='EE1111'))
>>> rule = Rule(type='cellIs', dxf=dxf, formula=["10"])

Because the signatures for some rules can be quite verbose there are also some convenience factories for creating them.

Builtin formats

The builtins conditional formats are:

  • ColorScale
  • IconSet
  • DataBar

Builtin formats contain a sequence of formatting settings which combine a type with an integer for comparison. Possible types are: ‘num’, ‘percent’, ‘max’, ‘min’, ‘formula’, ‘percentile’.

ColorScale

You can have color scales with 2 or 3 colors. 2 color scales produce a gradient from one color to another; 3 color scales use an additional color for 2 gradients.

The full syntax for creating a ColorScale rule is:

>>> from openpyxl.formatting.rule import ColorScale, FormatObject
>>> from openpyxl.styles import Color
>>> first = FormatObject(type='min')
>>> last = FormatObject(type='max')
>>> # colors match the format objects:
>>> colors = [Color('AA0000'), Color('00AA00')]
>>> cs2 = ColorScale(cfvo=[first, last], color=colors)
>>> # a three color scale would extend the sequences
>>> mid = FormatObject(type='num', val=40)
>>> colors.insert(1, Color('00AA00'))
>>> cs3 = ColorScale(cfvo=[first, mid, last], color=colors)
>>> # create a rule with the color scale
>>> from openpyxl.formatting.rule import Rule
>>> rule = Rule(type='colorScale', colorScale=cs3)

There is a convenience function for creating ColorScale rules

>>> from openpyxl.formatting.rule import ColorScaleRule
>>> rule = ColorScaleRule(start_type='percentile', start_value=10, start_color='FFAA0000',
...                       mid_type='percentile', mid_value=50, mid_color='FF0000AA',
...                       end_type='percentile', end_value=90, end_color='FF00AA00')
IconSet

Choose from the following set of icons: ‘3Arrows’, ‘3ArrowsGray’, ‘3Flags’, ‘3TrafficLights1’, ‘3TrafficLights2’, ‘3Signs’, ‘3Symbols’, ‘3Symbols2’, ‘4Arrows’, ‘4ArrowsGray’, ‘4RedToBlack’, ‘4Rating’, ‘4TrafficLights’, ‘5Arrows’, ‘5ArrowsGray’, ‘5Rating’, ‘5Quarters’

The full syntax for creating an IconSet rule is:

>>> from openpyxl.formatting.rule import IconSet, FormatObject
>>> first = FormatObject(type='percent', val=0)
>>> second = FormatObject(type='percent', val=33)
>>> third = FormatObject(type='percent', val=67)
>>> iconset = IconSet(iconSet='3TrafficLights1', cfvo=[first, second, third], showValue=None, percent=None, reverse=None)
>>> # assign the icon set to a rule
>>> from openpyxl.formatting.rule import Rule
>>> rule = Rule(type='iconSet', iconSet=iconset)

There is a convenience function for creating IconSet rules:

>>> from openpyxl.formatting.rule import IconSetRule
>>> rule = IconSetRule('5Arrows', 'percent', [10, 20, 30, 40, 50], showValue=None, percent=None, reverse=None)
DataBar

Currently, openpyxl supports the DataBars as defined in the original specification. Borders and directions were added in a later extension.

The full syntax for creating a DataBar rule is:

>>> from openpyxl.formatting.rule import DataBar, FormatObject
>>> first = FormatObject(type='min')
>>> second = FormatObject(type='max')
>>> data_bar = DataBar(cfvo=[first, second], color="638EC6", showValue=None, minLength=None, maxLength=None)
>>> # assign the data bar to a rule
>>> from openpyxl.formatting.rule import Rule
>>> rule = Rule(type='dataBar', dataBar=data_bar)

There is a convenience function for creating DataBar rules:

>>> from openpyxl.formatting.rule import DataBarRule
>>> rule = DataBarRule(start_type='percentile', start_value=10, end_type='percentile', end_value='90',
...                    color="FF638EC6", showValue="None", minLength=None, maxLength=None)
Standard conditional formats

The standard conditional formats are:

  • Average
  • Percent
  • Unique or duplicate
  • Value
  • Rank
>>> from openpyxl import Workbook
>>> from openpyxl.styles import Color, PatternFill, Font, Border
>>> from openpyxl.styles.differential import DifferentialStyle
>>> from openpyxl.formatting.rule import ColorScaleRule, CellIsRule, FormulaRule
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> # Create fill
>>> redFill = PatternFill(start_color='EE1111',
...                end_color='EE1111',
...                fill_type='solid')
>>>
>>> # Add a two-color scale
>>> # Takes colors in excel 'RRGGBB' style.
>>> ws.conditional_formatting.add('A1:A10',
...             ColorScaleRule(start_type='min', start_color='AA0000',
...                           end_type='max', end_color='00AA00')
...                           )
>>>
>>> # Add a three-color scale
>>> ws.conditional_formatting.add('B1:B10',
...                ColorScaleRule(start_type='percentile', start_value=10, start_color='AA0000',
...                            mid_type='percentile', mid_value=50, mid_color='0000AA',
...                            end_type='percentile', end_value=90, end_color='00AA00')
...                              )
>>>
>>> # Add a conditional formatting based on a cell comparison
>>> # addCellIs(range_string, operator, formula, stopIfTrue, wb, font, border, fill)
>>> # Format if cell is less than 'formula'
>>> ws.conditional_formatting.add('C2:C10',
...             CellIsRule(operator='lessThan', formula=['C$1'], stopIfTrue=True, fill=redFill))
>>>
>>> # Format if cell is between 'formula'
>>> ws.conditional_formatting.add('D2:D10',
...             CellIsRule(operator='between', formula=['1','5'], stopIfTrue=True, fill=redFill))
>>>
>>> # Format using a formula
>>> ws.conditional_formatting.add('E1:E10',
...             FormulaRule(formula=['ISBLANK(E1)'], stopIfTrue=True, fill=redFill))
>>>
>>> # Aside from the 2-color and 3-color scales, format rules take fonts, borders and fills for styling:
>>> myFont = Font()
>>> myBorder = Border()
>>> ws.conditional_formatting.add('E1:E10',
...             FormulaRule(formula=['E1=0'], font=myFont, border=myBorder, fill=redFill))
>>>
>>> # Highlight cells that contain particular text by using a special formula
>>> red_text = Font(color="9C0006")
>>> red_fill = PatternFill(bgColor="FFC7CE")
>>> dxf = DifferentialStyle(font=red_text, fill=red_fill)
>>> rule = Rule(type="containsText", operator="containsText", text="highlight", dxf=dxf)
>>> rule.formula = ['NOT(ISERROR(SEARCH("highlight",A1)))']
>>> ws.conditional_formatting.add('A1:F40', rule)
>>> wb.save("test.xlsx")
Formatting Entire Rows

Sometimes you want to apply a conditional format to more than one cell, say a row of cells which contain a particular value.

>>> ws.append(['Software', 'Developer', 'Version'])
>>> ws.append(['Excel', 'Microsoft', '2016'])
>>> ws.append(['openpyxl', 'Open source', '2.6'])
>>> ws.append(['OpenOffice', 'Apache', '4.1.4'])
>>> ws.append(['Word', 'Microsoft', '2010'])

We want to highlight the rows where the developer is Microsoft. We do this by creating an expression rule and using a formula to identify which rows contain software developed by Microsoft.

>>> red_fill = PatternFill(bgColor="FFC7CE")
>>> dxf = DifferentialStyle(fill=red_fill)
>>> r = Rule(type="expression", dxf=dxf, stopIfTrue=True)
>>> r.formula = ['$A2="Microsoft"']
>>> ws.conditional_formatting.add("A1:C10", r)

Note

The formula uses an absolute reference to the column referred to, B in this case; but a relative row number, in this case 1 to the range over which the format is applied. It can be tricky to get this right but the rule can be adjusted even after it has been added to the worksheet’s conditional format collection.

Inserting and deleting rows and columns, moving ranges of cells

Inserting rows and columns

You can insert rows or columns using the relevant worksheet methods:

The default is one row or column. For example to insert a row at 7 (before the existing row 7):

>>> ws.insert_rows(7)
Deleting rows and columns

To delete the columns F:H:

>>> ws.delete_cols(6, 3)

Note

Openpyxl does not manage dependencies, such as formulae, tables, charts, etc., when rows or columns are inserted or deleted. This is considered to be out of scope for a library that focuses on managing the file format. As a result, client code must implement the functionality required in any particular use case.

Moving ranges of cells

You can also move ranges of cells within a worksheet:

>>> ws.move_range("D4:F10", rows=-1, cols=2)

This will move the cells in the range D4:F10 up one row, and right two columns. The cells will overwrite any existing cells.

If cells contain formulae you can let openpyxl translate these for you, but as this is not always what you want it is disabled by default. Also only the formulae in the cells themselves will be translated. References to the cells from other cells or defined names will not be updated; you can use the Parsing Formulas translator to do this:

>>> ws.move_range("G4:H10", rows=1, cols=1, translate=True)

This will move the relative references in formulae in the range by one row and one column.

Merge / Unmerge cells

When you merge cells all cells but the top-left one are removed from the worksheet. To carry the border-information of the merged cell, the boundary cells of the merged cell are created as MergeCells which always have the value None. See Styling Merged Cells for information on formatting merged cells.

>>> from openpyxl.workbook import Workbook
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> ws.merge_cells('A2:D2')
>>> ws.unmerge_cells('A2:D2')
>>>
>>> # or equivalently
>>> ws.merge_cells(start_row=2, start_column=1, end_row=4, end_column=4)
>>> ws.unmerge_cells(start_row=2, start_column=1, end_row=4, end_column=4)

Additional Worksheet Properties

These are advanced properties for particular behaviours, the most used ones are the “fitTopage” page setup property and the tabColor that define the background color of the worksheet tab.

Available properties for worksheets
  • “enableFormatConditionsCalculation”
  • “filterMode”
  • “published”
  • “syncHorizontal”
  • “syncRef”
  • “syncVertical”
  • “transitionEvaluation”
  • “transitionEntry”
  • “tabColor”
Available fields for page setup properties

“autoPageBreaks” “fitToPage”

Available fields for outlines
  • “applyStyles”
  • “summaryBelow”
  • “summaryRight”
  • “showOutlineSymbols”

Search ECMA-376 pageSetup for more details.

Note

By default, outline properties are intitialized so you can directly modify each of their 4 attributes, while page setup properties don’t. If you want modify the latter, you should first initialize a openpyxl.worksheet.properties.PageSetupProperties object with the required parameters. Once done, they can be directly modified by the routine later if needed.

>>> from openpyxl.workbook import Workbook
>>> from openpyxl.worksheet.properties import WorksheetProperties, PageSetupProperties
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> wsprops = ws.sheet_properties
>>> wsprops.tabColor = "1072BA"
>>> wsprops.filterMode = False
>>> wsprops.pageSetUpPr = PageSetupProperties(fitToPage=True, autoPageBreaks=False)
>>> wsprops.outlinePr.summaryBelow = False
>>> wsprops.outlinePr.applyStyles = True
>>> wsprops.pageSetUpPr.autoPageBreaks = True
Worksheet Views

There are also several convenient properties defined as worksheet views. You can use ws.sheet_view to set sheet attributes such as zoom, show formulas or if the tab is selected.

>>> from openpyxl.workbook import Workbook
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> ws.sheet_view.zoom = 85 # Sets 85% zoom
>>> ws.sheet_view.showFormulas = True
>>> ws.sheet_view.tabSelected = True
Fold (outline)
>>> import openpyxl
>>> wb = openpyxl.Workbook()
>>> ws = wb.create_sheet()
>>> ws.column_dimensions.group('A','D', hidden=True)
>>> ws.row_dimensions.group(1,10, hidden=True)
>>> wb.save('group.xlsx')

Validating cells

Data validators can be applied to ranges of cells but are not enforced or evaluated. Ranges do not have to be contiguous: eg. “A1 B2:B5” is contains A1 and the cells B2 to B5 but not A2 or B2.

Examples
>>> from openpyxl import Workbook
>>> from openpyxl.worksheet.datavalidation import DataValidation
>>>
>>> # Create the workbook and worksheet we'll be working with
>>> wb = Workbook()
>>> ws = wb.active
>>>
>>> # Create a data-validation object with list validation
>>> dv = DataValidation(type="list", formula1='"Dog,Cat,Bat"', allow_blank=True)
>>>
>>> # Optionally set a custom error message
>>> dv.error ='Your entry is not in the list'
>>> dv.errorTitle = 'Invalid Entry'
>>>
>>> # Optionally set a custom prompt message
>>> dv.prompt = 'Please select from the list'
>>> dv.promptTitle = 'List Selection'
>>>
>>> # Add the data-validation object to the worksheet
>>> ws.add_data_validation(dv)
>>> # Create some cells, and add them to the data-validation object
>>> c1 = ws["A1"]
>>> c1.value = "Dog"
>>> dv.add(c1)
>>> c2 = ws["A2"]
>>> c2.value = "An invalid value"
>>> dv.add(c2)
>>>
>>> # Or, apply the validation to a range of cells
>>> dv.add('B1:B1048576') # This is the same as for the whole of column B
>>>
>>> # Check with a cell is in the validator
>>> "B4" in dv
True

Note

Validations without any cell ranges will be ignored when saving a workbook.

Note

Excel and LibreOffice interpret the parameter showDropDown=True as the dropdown arrow should be hidden.

Other validation examples

Any whole number:

dv = DataValidation(type="whole")

Any whole number above 100:

dv = DataValidation(type="whole",
                    operator="greaterThan",
                    formula1=100)

Any decimal number:

dv = DataValidation(type="decimal")

Any decimal number between 0 and 1:

dv = DataValidation(type="decimal",
                    operator="between",
                    formula1=0,
                    formula2=1)

Any date:

dv = DataValidation(type="date")

or time:

dv = DataValidation(type="time")

Any string at most 15 characters:

dv = DataValidation(type="textLength",
                    operator="lessThanOrEqual"),
                    formula1=15)

Cell range validation:

from openpyxl.utils import quote_sheetname
dv = DataValidation(type="list",
                    formula1="{0}!$B$1:$B$10".format(quote_sheetname(sheetname))
                    )

Custom rule:

dv = DataValidation(type="custom",
                    formula1"=SOMEFORMULA")

Worksheet Tables

Worksheet tables are references to groups of cells. This makes certain operations such as styling the cells in a table easier.

Creating a table
from openpyxl import Workbook
from openpyxl.worksheet.table import Table, TableStyleInfo

wb = Workbook()
ws = wb.active

data = [
    ['Apples', 10000, 5000, 8000, 6000],
    ['Pears',   2000, 3000, 4000, 5000],
    ['Bananas', 6000, 6000, 6500, 6000],
    ['Oranges',  500,  300,  200,  700],
]

# add column headings. NB. these must be strings
ws.append(["Fruit", "2011", "2012", "2013", "2014"])
for row in data:
    ws.append(row)

tab = Table(displayName="Table1", ref="A1:E5")

# Add a default style with striped rows and banded columns
style = TableStyleInfo(name="TableStyleMedium9", showFirstColumn=False,
                       showLastColumn=False, showRowStripes=True, showColumnStripes=True)
tab.tableStyleInfo = style

'''
Table must be added using ws.add_table() method to avoid duplicate names.
Using this method ensures table name is unque through out defined names and all other table name. 
'''
ws.add_table(tab)
wb.save("table.xlsx")

Table names must be unique within a workbook. By default tables are created with a header from the first row and filters for all the columns and table headers and column headings must always contain strings.

Warning

In write-only mode you must add column headings to tables manually and the values must always be the same as the values of the corresponding cells (ee below for an example of how to do this), otherwise Excel may consider the file invalid and remove the table.

Styles are managed using the the TableStyleInfo object. This allows you to stripe rows or columns and apply the different colour schemes.

Working with Tables

ws.tables is a dictionary-like object of all the tables in a particular worksheet:

>>> ws.tables
{"Table1",  <openpyxl.worksheet.table.Table object>}
Get Table by name or range
>>> ws.tables["Table1"]
or
>>> ws.tables["A1:D10"]
Iterate through all tables in a worksheet
>>> for table in ws.tables.values():
>>>    print(table)
Get table name and range of all tables in a worksheet

Returns a list of table name and their ranges.

>>> ws.tables.items()
>>> [("Table1", "A1:D10")]
Delete a table
>>> del ws.tables["Table1"]
The number of tables in a worksheet
>>> len(ws.tables)
>>> 1
Manually adding column headings

In write-only mode you can either only add tables without headings:

>>> table.headerRowCount = False

Or initialise the column headings manually:

>>> headings = ["Fruit", "2011", "2012", "2013", "2014"] # all values must be strings
>>> table._initialise_columns()
>>> for column, value in zip(table.tableColumns, headings):
    column.name = value
Filters

Filters will be added automatically to tables that contain header rows. It is not possible to create tables with header rows without filters.

Table as a Print Area

Excel can produce documents with the print area set to the table name. Openpyxl cannot, however, resolve such dynamic defintions and will raise a warning when trying to do so.

If you need to handle this you can extract the range of the table and define the print area as the appropriate cell range.

>>> from openpyxl import load_workbook
>>> wb = load_workbook("QueryTable.xlsx")
>>> ws = wb.active
>>> table_range = ws.tables["InvoiceData"]
>>> ws.print_area = table_range.ref        # Ref is the cell range the table currently covers

Using filters and sorts

It’s possible to filter single range of values in a worksheet by adding an autofilter. If you need to filter multiple ranges, you can use tables and apply a separate filter for each table.

Note

Filters and sorts can only be configured by openpyxl but will need to be applied in applications like Excel. This is because they actually rearrange, format and hide rows in the range.

To add a filter you define a range and then add columns. You set the range over which the filter by setting the ref attribute. Filters are then applied to columns in the range using a zero-based index, eg. in a range from A1:H10, colId 1 refers to column B. Openpyxl does not check the validity of such assignments.

from openpyxl import Workbook
from openpyxl.worksheet.filters import (
    FilterColumn,
    CustomFilter,
    CustomFilters,
    DateGroupItem,
    Filters,
    )

wb = Workbook()
ws = wb.active

data = [
    ["Fruit", "Quantity"],
    ["Kiwi", 3],
    ["Grape", 15],
    ["Apple", 3],
    ["Peach", 3],
    ["Pomegranate", 3],
    ["Pear", 3],
    ["Tangerine", 3],
    ["Blueberry", 3],
    ["Mango", 3],
    ["Watermelon", 3],
    ["Blackberry", 3],
    ["Orange", 3],
    ["Raspberry", 3],
    ["Banana", 3]
]

for r in data:
    ws.append(r)

filters = ws.auto_filter
filters.ref = "A1:B15"
col = FilterColumn(colId=0) # for column A
col.filters = Filters(filter=["Kiwi", "Apple", "Mango"]) # add selected values
filters.filterColumn.append(col) # add filter to the worksheet

ws.auto_filter.add_sort_condition("B2:B15")

wb.save("filtered.xlsx")

This will add the relevant instructions to the file but will neither actually filter nor sort.

"Filter and sort prepared but not executed for a range of cells"
Advanced filters

The following predefined filters can be used: CustomFilter, DateGroupItem, DynamicFilter, ColorFilter, IconFilter and Top10 ColorFilter, IconFilter and Top10 all interact with conditional formats.

The signature and structure of the different kinds of filter varies significantly. As such it makes sense to familiarise yourself with either the openpyxl source code or the OOXML specification.

CustomFilter

CustomFilters can have one or two conditions which will operate either independently (the default), or combined by setting the and_ attribute. Filter can use the following operators: 'equal', 'lessThan', 'lessThanOrEqual', 'notEqual', 'greaterThanOrEqual', 'greaterThan'.

Filter values < 10 and > 90:

from openpyxl.worksheet.filters import CustomFilter, CustomFilters
flt1 = CustomFilter(operator="lessThan", val=10)
flt2 = CustomFilter(operator=greaterThan, val=90)

cfs = CustomFilters(customFilter=[flt1, flt2])
col = FilterColumn(colId=2, customFilters=cfs) # apply to **third** column in the range
filters.filter.append(col)

To combine the filters:

cfs.and_ = True

In addition, Excel has non-standardised functionality for pattern matching with strings. The options in Excel: begins with, ends with, contains and their negatives are all implemented using the equal (or for negatives notEqual) operator and wildcard in the value.

For example: for “begins with a”, use a*; for “ends with a”, use *a; and for “contains a””, use *a*.

DateGroupItem

Date filters can be set to allow filtering by different datetime criteria such as year, month or hour. As they are similar to lists of values you can have multiple items.

To filter by the month of March:

from openpyxl.worksheet.filters import DateGroupItem
df1 = DateGroupItem(month=3, dateTimeGrouping="month")
col = FilterColumn(colId=1) # second column
col.filters.dateGroupItem.append(df1)

df2 = DateGroupItem(year=1984, dateTimeGrouping="year") # add another element
col.filters.dateGroupItem.append(df2)
filters.filter.append(col)

Pivot Tables

openpyxl provides read-support for pivot tables so that they will be preserved in existing files. The specification for pivot tables, while extensive, is not very clear and it is not intended that client code should be able to create pivot tables. However, it should be possible to edit and manipulate existing pivot tables, eg. change their ranges or whether they should update automatically settings.

As is the case for charts, images and tables there is currently no management API for pivot tables so that client code will have to loop over the _pivots list of a worksheet.

Example
from openpyxl import load_workbook
wb = load_workbook("campaign.xlsx")
ws = wb["Results"]
pivot = ws._pivots[0] # any will do as they share the same cache
pivot.cache.refreshOnLoad = True

For further information see openpyxl.pivot.cache.CacheDefinition

Comments

Warning

Openpyxl currently supports the reading and writing of comment text only. Formatting information is lost. Comment dimensions are lost upon reading, but can be written. Comments are not currently supported if read_only=True is used.

Adding a comment to a cell

Comments have a text attribute and an author attribute, which must both be set

>>> from openpyxl import Workbook
>>> from openpyxl.comments import Comment
>>> wb = Workbook()
>>> ws = wb.active
>>> comment = ws["A1"].comment
>>> comment = Comment('This is the comment text', 'Comment Author')
>>> comment.text
'This is the comment text'
>>> comment.author
'Comment Author'

If you assign the same comment to multiple cells then openpyxl will automatically create copies

>>> from openpyxl import Workbook
>>> from openpyxl.comments import Comment
>>> wb=Workbook()
>>> ws=wb.active
>>> comment = Comment("Text", "Author")
>>> ws["A1"].comment = comment
>>> ws["B2"].comment = comment
>>> ws["A1"].comment is comment
True
>>> ws["B2"].comment is comment
False
Loading and saving comments

Comments present in a workbook when loaded are stored in the comment attribute of their respective cells automatically. Formatting information such as font size, bold and italics are lost, as are the original dimensions and position of the comment’s container box.

Comments remaining in a workbook when it is saved are automatically saved to the workbook file.

Comment dimensions can be specified for write-only. Comment dimension are in pixels.

>>> from openpyxl import Workbook
>>> from openpyxl.comments import Comment
>>> from openpyxl.utils import units
>>>
>>> wb=Workbook()
>>> ws=wb.active
>>>
>>> comment = Comment("Text", "Author")
>>> comment.width = 300
>>> comment.height = 50
>>>
>>> ws["A1"].comment = comment
>>>
>>> wb.save('commented_book.xlsx')

If needed, openpyxl.utils.units contains helper functions for converting from other measurements such as mm or points to pixels:

>>> from openpyxl import Workbook
>>> from openpyxl.comments import Comment
>>> from openpyxl.utils import units
>>>
>>> wb=Workbook()
>>> ws=wb.active
>>>
>>> comment = Comment("Text", "Author")
>>> comment.width = units.points_to_pixels(300)
>>> comment.height = units.points_to_pixels(50)
>>>
>>> ws["A1"].comment = comment

Dates and Times

Dates and times can be stored in two distinct ways in XLSX files: as an ISO 8601 formatted string or as a single number. openpyxl supports both representations and translates between them and Python’s datetime module representations when reading from and writing to files. In either representation, the maximum date and time precision in XLSX files is millisecond precision.

XLSX files are not suitable for storing historic dates (before 1900), due to bugs in Excel that cannot be fixed without causing backward compatibility problems. To discourage users from trying anyway, Excel deliberately refuses to recognize and display such dates. Consequently, it is not advised to use openpyxl for such purposes either, especially when exchanging files with others.

Timezones

The date and time representations in Excel do not support timezones, therefore openpyxl can only deal with naive datetime/time objects. Any timezone information attached to Python datetimes must be stripped off by the user before datetimes can be stored in XLSX files.

Using the ISO 8601 format

To make openpyxl store dates and times in the ISO 8601 format on writing your file, set the workbook’s iso_dates flag to True:

>>> import openpyxl
>>> wb = openpyxl.Workbook()
>>> wb.iso_dates = True

The benefit of using this format is that the meaning of the stored information is not subject to interpretation, as it is with the single number format [1].

The Office Open XML standard does not specify a supported subset of the ISO 8601 duration format for representing time interval durations. openpyxl therefore always uses the single number format for timedelta values when writing them to file.

The 1900 and 1904 date systems

The ‘date system’ of an XLSX file determines how dates and times in the single number representation are interpreted. XLSX files always use one of two possible date systems:

  • In the 1900 date system (the default), the reference date (with number 1) is 1900-01-01.
  • In the 1904 date system, the reference date (with number 0) is 1904-01-01.

Complications arise not only from the different start numbers of the reference dates, but also from the fact that the 1900 date system has a built-in (but wrong) assumption that the year 1900 had been a leap year. Excel deliberately refuses to recognize and display dates before the reference date correctly, in order to discourage people from storing historical data.

More information on this issue is available from Microsoft:

In workbooks using the 1900 date system, openpyxl behaves the same as Excel when translating between the worksheets’ date/time numbers and Python datetimes in January and February 1900. The only exception is 29 February 1900, which cannot be represented as a Python datetime object since it is not a valid date.

You can get the date system of a workbook like this:

>>> import openpyxl
>>> wb = openpyxl.Workbook()
>>> if wb.epoch == openpyxl.utils.datetime.CALENDAR_WINDOWS_1900:
...     print("This workbook is using the 1900 date system.")
...
This workbook is using the 1900 date system.

and set it like this:

>>> wb.epoch = openpyxl.utils.datetime.CALENDAR_MAC_1904
Handling timedelta values

Excel users can use number formats resembling [h]:mm:ss or [mm]:ss to display time interval durations, which openpyxl considers to be equivalent to timedeltas in Python. openpyxl recognizes these number formats when reading XLSX files and returns datetime.timedelta values for the corresponding cells.

When writing timedelta values from worksheet cells to file, openpyxl uses the [h]:mm:ss number format for these cells.

Footnotes

[1]For example, the serial 1 in an Excel worksheet can be interpreted as 00:00, as 24:00, as 1900-01-01, as 1440 (minutes), etc., depending solely on the formatting applied.

Simple Formualae

Using formulae

Formualae may be parsed and modified as well.

>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>> # add a simple formula
>>> ws["A1"] = "=SUM(1, 1)"
>>> wb.save("formula.xlsx")

Warning

NB you must use the English name for a function and function arguments must be separated by commas and not other punctuation such as semi-colons.

openpyxl never evaluates formula but it is possible to check the name of a formula:

>>> from openpyxl.utils import FORMULAE
>>> "HEX2DEC" in FORMULAE
True

If you’re trying to use a formula that isn’t known this could be because you’re using a formula that was not included in the initial specification. Such formulae must be prefixed with _xlfn. to work.

Special formulae

Openpyxl also supports two special kinds of formulae: Array Formulae and Data Table Formulae. Given the frequent use of “data tables” within OOXML the latter are particularly confusing.

In general, support for these kinds of formulae is limited to preserving them in Excel files but the implementation is complete.

Array Formulae

Although array formulae are applied to a range of cells, they will only be visible for the top-left cell of the array. This can be confusing and a source of errors. To check for array formulae in a worksheet you can use the ws.array_formulae property which returns a dictionary of cells with array formulae definitions and the ranges they apply to.

Creating your own array formulae is fairly straightforward

>>> from openpyxl import Workbook
>>> from openpyxl.worksheet.formula import ArrayFormula
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>> ws["E2"] = ArrayFormula("E2:E11", "=SUM(C2:C11*D2:D11)")

Note

The top-left most cell of the array formula must be the cell you assign it to, otherwise you will get errors on workbook load.

Note

In Excel the formula will appear in all the cells in the range in curly brackets {} but you should never use these in your own formulae.

Data Table Formulae

As with array formulae, data table formulae are applied to a range of cells. The table object themselves contain no formulae but only the definition of table: the cells covered and whether it is one dimensional or not, etc. For further information refer to the OOXML specification.

To find out whether a worksheet has any data tables, use the ws.table_formulae property.

Defined Names

The specification has the following to say about defined names:

“Defined names are descriptive text that is used to represents a cell, range of cells, formula, or constant value.”

This means they are very loosely defined. They might contain a constant, a formula, a single cell reference, a range of cells or multiple ranges of cells across different worksheets. Or all of the above. Cell references or ranges must use absolute coordinates and always include the name of the worksheet they’re in. Use the utilities absolute_coordinate() and quote_sheetname() to do this.

Defined names can either be restricted to individual worksheets or available globally for the whole workbook. Names must be unique within a collection; new items will replace existing ones with the name.

Accessing Global Definitions

Global definitions are stored in the workbook collection:

defn = wb.defined_names["my_range"]
# the destinations attribute contains a list of ranges in the definitions
dests = defn.destinations # returns a generator of (worksheet title, cell range) tuples

cells = []
for title, coord in dests:
    ws = wb[title]
    cells.append(ws[coord])
Accessing Worksheet Definitions

Definitions are assigned to a specific worksheet are only accessible from that worksheet:

ws = wb["Sheet"]
defn = ws.defined_names["private_range"]
Creating a Global Definition

Global definitions are assigned to the workbook collection:

from openpyxl import Workbook
from openpyxl.workbook.defined_name import DefinedName
from openpyxl.utils import quote_sheetname, absolute_coordinate
wb = Workbook()
ws = wb.active
# make sure sheetnames and cell references are quoted correctly
ref =  "{quote_sheetname(ws.title)}!{absolute_coordinate('A1:A5')}"

defn = DefinedName("global_range", attr_text=ref)
wb.defined_names["global_range"] = defn

# key and `name` must be the same, the `.add()` method makes this easy
wb.defined_names.add(new_range)
Creating a Worksheet Definition

Definitions are assigned to a specific worksheet are only accessible from that worksheet:

# create a local named range (only valid for a specific sheet)
ws = wb["Sheet"]
ws.title = "My Sheet"
# make sure sheetnames  and cell referencesare quoted correctly
ref = f"{quote_sheetname(ws.title)}!{absolute_coordinate('A6')}"

defn = DefinedName("private_range", attr_text=ref)
ws.defined_names.add(defn)
print(ws.defined_names["private_range"].attr_text)
Dynamic Named Ranges

Wherever relevant and possible, openpyxl will try and convert names that contain cell ranges into relevant object. For example, print areas and print titles, which are special cases of defined names, are mapped to print title and print area objects within a worksheet.

It is, however, possible to define ranges dynamically using other defined names, or objects such as tables. As openpyxl is unable to resolve such definitions, it will skip the definition and raise a warning. If you need to handle this you can extract the range of the defined name and set the print area as the appropriate cell range.

>>> from openpyxl import load_workbook
>>> wb = load_workbook("Example.xlsx")
>>> ws = wb.active
>>> area = ws.defined_names["TestArea"] # Globally defined named ranges can be used too
>>> ws.print_area = area.value          # value is the cell range the defined name currently covers

Custom Document Properties

It is possible to add one or more CustomDocumentProperty objects to a workbook. These require a unique name (string) and can be one of 6 types:

  • StringProperty
  • IntProperty
  • FloatProperty
  • DateTimeProperty
  • BoolProperty
  • LinkProperty

LinkProperties are always associated with a defined name range.

These properties are globally for a workbook and accessed from the custom_doc_props attribute.

Sample use

Looping over all the custom properties (“custom_doc_props”):

>>> for prop in wb.custom_doc_props.props:
>>>    print(f"{prop.name}: {prop.value}")

Adding a new property:

from openpyxl.packaging.custom import (
    BoolProperty,
    DateTimeProperty,
    FloatProperty,
    IntProperty,
    LinkProperty,
    StringProperty,
    CustomPropertyList,
)

props = CustomePropertyList()
props.append(StringProperty(name="PropName1", value="Something"))
Deleting properties
wb.custom_doc_props.append(StringProperty(name="PropName6", value="Something"))
# check the property
prop = wb.custom_doc_props["PropName6"]

# delete the string property:
del prop["PropName6"]

# save the file
wb.save('outfile.xlsx')

Note

Currently not all possible property types are supported. If openpyxl cannot read a particular type, it will provide a warning and ignore it.

Protection

Warning

Password protecting a workbook or worksheet only provides a quite basic level of security. The data is not encrypted, so can be modified by any number of freely available tools. In fact the specification states: “Worksheet or workbook element protection should not be confused with file security. It is meant to make your workbook safe from unintentional modification, and cannot protect it from malicious modification.”

Openpyxl provides support for protecting a workbook and worksheet from modification. The Open XML “Legacy Password Hash Algorithm” is used to generate hashed password values unless another algorithm is explicitly configured.

Workbook Protection

To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets, you can protect the structure of your workbook with a password. The password can be set using the openpyxl.workbook.protection.WorkbookProtection.workbookPassword() property

>>> wb.security.workbookPassword = '...'
>>> wb.security.lockStructure = True

Similarly removing change tracking and change history from a shared workbook can be prevented by setting another password. This password can be set using the openpyxl.workbook.protection.WorkbookProtection.revisionsPassword() property

>>> wb.security.revisionsPassword = '...'

Other properties on the openpyxl.workbook.protection.WorkbookProtection object control exactly what restrictions are in place, but these will only be enforced if the appropriate password is set.

Specific setter functions are provided if you need to set the raw password value without using the default hashing algorithm - e.g.

hashed_password = ...
wb.security.set_workbook_password(hashed_password, already_hashed=True)
Worksheet Protection

Various aspects of a worksheet can also be locked by setting attributes on the openpyxl.worksheet.protection.SheetProtection object. Unlike workbook protection, sheet protection may be enabled with or without using a password. Sheet protection is enabled using the openpxyl.worksheet.protection.SheetProtection.sheet attribute or calling enable() or disable():

>>> ws = wb.active
>>> ws.protection.sheet = True
>>> ws.protection.enable()
>>> ws.protection.disable()

If no password is specified, users can disable configured sheet protection without specifying a password. Otherwise they must supply a password to change configured protections. The password is set using the openpxyl.worksheet.protection.SheetProtection.password() property

>>> ws = wb.active
>>> ws.protection.password = '...'

Charts

Chart types

The following charts are available:

Area Charts
2D Area Charts

Area charts are similar to line charts with the addition that the area underneath the plotted line is filled. Different variants are available by setting the grouping to “standard”, “stacked” or “percentStacked”; “standard” is the default.

from openpyxl import Workbook
from openpyxl.chart import (
    AreaChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Number', 'Batch 1', 'Batch 2'],
    [2, 40, 30],
    [3, 40, 25],
    [4, 50, 30],
    [5, 30, 10],
    [6, 25, 5],
    [7, 50, 10],
]

for row in rows:
    ws.append(row)

chart = AreaChart()
chart.title = "Area Chart"
chart.style = 13
chart.x_axis.title = 'Test'
chart.y_axis.title = 'Percentage'

cats = Reference(ws, min_col=1, min_row=1, max_row=7)
data = Reference(ws, min_col=2, min_row=1, max_col=3, max_row=7)
chart.add_data(data, titles_from_data=True)
chart.set_categories(cats)

ws.add_chart(chart, "A10")

wb.save("area.xlsx")
"Sample area charts"
3D Area Charts

You can also create 3D area charts

from openpyxl import Workbook
from openpyxl.chart import (
    AreaChart3D,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Number', 'Batch 1', 'Batch 2'],
    [2, 30, 40],
    [3, 25, 40],
    [4 ,30, 50],
    [5 ,10, 30],
    [6,  5, 25],
    [7 ,10, 50],
]

for row in rows:
    ws.append(row)

chart = AreaChart3D()
chart.title = "Area Chart"
chart.style = 13
chart.x_axis.title = 'Test'
chart.y_axis.title = 'Percentage'
chart.legend = None

cats = Reference(ws, min_col=1, min_row=1, max_row=7)
data = Reference(ws, min_col=2, min_row=1, max_col=3, max_row=7)
chart.add_data(data, titles_from_data=True)
chart.set_categories(cats)

ws.add_chart(chart, "A10")

wb.save("area3D.xlsx")

This produces a simple 3D area chart where the third axis can be used to replace the legend:

"Sample 3D area chart with a series axis"
Bar and Column Charts

In bar charts values are plotted as either horizontal bars or vertical columns.

Vertical, Horizontal and Stacked Bar Charts

Note

The following settings affect the different chart types.

Switch between vertical and horizontal bar charts by setting type to col or bar respectively.

When using stacked charts the overlap needs to be set to 100.

If bars are horizontal, x and y axes are reversed.

"Sample bar charts"
from openpyxl import Workbook
from openpyxl.chart import BarChart, Series, Reference

wb = Workbook(write_only=True)
ws = wb.create_sheet()

rows = [
    ('Number', 'Batch 1', 'Batch 2'),
    (2, 10, 30),
    (3, 40, 60),
    (4, 50, 70),
    (5, 20, 10),
    (6, 10, 40),
    (7, 50, 30),
]


for row in rows:
    ws.append(row)


chart1 = BarChart()
chart1.type = "col"
chart1.style = 10
chart1.title = "Bar Chart"
chart1.y_axis.title = 'Test number'
chart1.x_axis.title = 'Sample length (mm)'

data = Reference(ws, min_col=2, min_row=1, max_row=7, max_col=3)
cats = Reference(ws, min_col=1, min_row=2, max_row=7)
chart1.add_data(data, titles_from_data=True)
chart1.set_categories(cats)
chart1.shape = 4
ws.add_chart(chart1, "A10")

from copy import deepcopy

chart2 = deepcopy(chart1)
chart2.style = 11
chart2.type = "bar"
chart2.title = "Horizontal Bar Chart"

ws.add_chart(chart2, "G10")


chart3 = deepcopy(chart1)
chart3.type = "col"
chart3.style = 12
chart3.grouping = "stacked"
chart3.overlap = 100
chart3.title = 'Stacked Chart'

ws.add_chart(chart3, "A27")


chart4 = deepcopy(chart1)
chart4.type = "bar"
chart4.style = 13
chart4.grouping = "percentStacked"
chart4.overlap = 100
chart4.title = 'Percent Stacked Chart'

ws.add_chart(chart4, "G27")

wb.save("bar.xlsx")

This will produce four charts illustrating the various possibilities.

3D Bar Charts

You can also create 3D bar charts

from openpyxl import Workbook
from openpyxl.chart import (
    Reference,
    Series,
    BarChart3D,
)

wb = Workbook()
ws = wb.active

rows = [
    (None, 2013, 2014),
    ("Apples", 5, 4),
    ("Oranges", 6, 2),
    ("Pears", 8, 3)
]

for row in rows:
    ws.append(row)

data = Reference(ws, min_col=2, min_row=1, max_col=3, max_row=4)
titles = Reference(ws, min_col=1, min_row=2, max_row=4)
chart = BarChart3D()
chart.title = "3D Bar Chart"
chart.add_data(data=data, titles_from_data=True)
chart.set_categories(titles)

ws.add_chart(chart, "E5")
wb.save("bar3d.xlsx")

This produces a simple 3D bar chart

"Sample 3D bar chart"
Bubble Charts

Bubble charts are similar to scatter charts but use a third dimension to determine the size of the bubbles. Charts can include multiple series.

"""
Sample bubble chart
"""

from openpyxl import Workbook
from openpyxl.chart import Series, Reference, BubbleChart

wb = Workbook()
ws = wb.active

rows = [
    ("Number of Products", "Sales in USD", "Market share"),
    (14, 12200, 15),
    (20, 60000, 33),
    (18, 24400, 10),
    (22, 32000, 42),
    (),
    (12, 8200, 18),
    (15, 50000, 30),
    (19, 22400, 15),
    (25, 25000, 50),
]

for row in rows:
    ws.append(row)

chart = BubbleChart()
chart.style = 18 # use a preset style

# add the first series of data
xvalues = Reference(ws, min_col=1, min_row=2, max_row=5)
yvalues = Reference(ws, min_col=2, min_row=2, max_row=5)
size = Reference(ws, min_col=3, min_row=2, max_row=5)
series = Series(values=yvalues, xvalues=xvalues, zvalues=size, title="2013")
chart.series.append(series)

# add the second
xvalues = Reference(ws, min_col=1, min_row=7, max_row=10)
yvalues = Reference(ws, min_col=2, min_row=7, max_row=10)
size = Reference(ws, min_col=3, min_row=7, max_row=10)
series = Series(values=yvalues, xvalues=xvalues, zvalues=size, title="2014")
chart.series.append(series)

# place the chart starting in cell E1
ws.add_chart(chart, "E1")
wb.save("bubble.xlsx")

This will produce a bubble chart with two series and should look something like this:

"Sample bubble chart"
Line Charts
Line Charts

Line charts allow data to be plotted against a fixed axis. They are similar to scatter charts, the main difference is that with line charts each data series is plotted against the same values. Different kinds of axes can be used for the secondary axes.

Similar to bar charts there are three kinds of line charts: standard, stacked and percentStacked.

from datetime import date

from openpyxl import Workbook
from openpyxl.chart import (
    LineChart,
    Reference,
)
from openpyxl.chart.axis import DateAxis

wb = Workbook()
ws = wb.active

rows = [
    ['Date', 'Batch 1', 'Batch 2', 'Batch 3'],
    [date(2015,9, 1), 40, 30, 25],
    [date(2015,9, 2), 40, 25, 30],
    [date(2015,9, 3), 50, 30, 45],
    [date(2015,9, 4), 30, 25, 40],
    [date(2015,9, 5), 25, 35, 30],
    [date(2015,9, 6), 20, 40, 35],
]

for row in rows:
    ws.append(row)

c1 = LineChart()
c1.title = "Line Chart"
c1.style = 13
c1.y_axis.title = 'Size'
c1.x_axis.title = 'Test Number'

data = Reference(ws, min_col=2, min_row=1, max_col=4, max_row=7)
c1.add_data(data, titles_from_data=True)

# Style the lines
s1 = c1.series[0]
s1.marker.symbol = "triangle"
s1.marker.graphicalProperties.solidFill = "FF0000" # Marker filling
s1.marker.graphicalProperties.line.solidFill = "FF0000" # Marker outline

s1.graphicalProperties.line.noFill = True

s2 = c1.series[1]
s2.graphicalProperties.line.solidFill = "00AAAA"
s2.graphicalProperties.line.dashStyle = "sysDot"
s2.graphicalProperties.line.width = 100050 # width in EMUs

s2 = c1.series[2]
s2.smooth = True # Make the line smooth

ws.add_chart(c1, "A10")

from copy import deepcopy
stacked = deepcopy(c1)
stacked.grouping = "stacked"
stacked.title = "Stacked Line Chart"
ws.add_chart(stacked, "A27")

percent_stacked = deepcopy(c1)
percent_stacked.grouping = "percentStacked"
percent_stacked.title = "Percent Stacked Line Chart"
ws.add_chart(percent_stacked, "A44")

# Chart with date axis
c2 = LineChart()
c2.title = "Date Axis"
c2.style = 12
c2.y_axis.title = "Size"
c2.y_axis.crossAx = 500
c2.x_axis = DateAxis(crossAx=100)
c2.x_axis.number_format = 'd-mmm'
c2.x_axis.majorTimeUnit = "days"
c2.x_axis.title = "Date"

c2.add_data(data, titles_from_data=True)
dates = Reference(ws, min_col=1, min_row=2, max_row=7)
c2.set_categories(dates)

ws.add_chart(c2, "A61")

wb.save("line.xlsx")
"Sample line charts"
3D Line Charts

In 3D line charts the third axis is the same as the legend for the series.

from datetime import date

from openpyxl import Workbook
from openpyxl.chart import (
    LineChart3D,
    Reference,
)
from openpyxl.chart.axis import DateAxis

wb = Workbook()
ws = wb.active

rows = [
    ['Date', 'Batch 1', 'Batch 2', 'Batch 3'],
    [date(2015,9, 1), 40, 30, 25],
    [date(2015,9, 2), 40, 25, 30],
    [date(2015,9, 3), 50, 30, 45],
    [date(2015,9, 4), 30, 25, 40],
    [date(2015,9, 5), 25, 35, 30],
    [date(2015,9, 6), 20, 40, 35],
]

for row in rows:
    ws.append(row)

c1 = LineChart3D()
c1.title = "3D Line Chart"
c1.legend = None
c1.style = 15
c1.y_axis.title = 'Size'
c1.x_axis.title = 'Test Number'

data = Reference(ws, min_col=2, min_row=1, max_col=4, max_row=7)
c1.add_data(data, titles_from_data=True)

ws.add_chart(c1, "A10")

wb.save("line3D.xlsx")
"Sample 3D line chart"
Scatter Charts

Scatter, or xy, charts are similar to some line charts. The main difference is that one series of values is plotted against another. This is useful where values are unordered.

from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Size', 'Batch 1', 'Batch 2'],
    [2, 40, 30],
    [3, 40, 25],
    [4, 50, 30],
    [5, 30, 25],
    [6, 25, 35],
    [7, 20, 40],
]

for row in rows:
    ws.append(row)

chart = ScatterChart()
chart.title = "Scatter Chart"
chart.style = 13
chart.x_axis.title = 'Size'
chart.y_axis.title = 'Percentage'

xvalues = Reference(ws, min_col=1, min_row=2, max_row=7)
for i in range(2, 4):
    values = Reference(ws, min_col=i, min_row=1, max_row=7)
    series = Series(values, xvalues, title_from_data=True)
    chart.series.append(series)

ws.add_chart(chart, "A10")

wb.save("scatter.xlsx")
"Sample scatter chart"

Note

The specification says that there are the following types of scatter charts: ‘line’, ‘lineMarker’, ‘marker’, ‘smooth’, ‘smoothMarker’. However, at least in Microsoft Excel, this is just a shortcut for other settings that otherwise have no effect. For consistency with line charts, the style for each series should be set manually.

Pie Charts
Pie Charts

Pie charts plot data as slices of a circle with each slice representing the percentage of the whole. Slices are plotted in a clockwise direction with 0° being at the top of the circle. Pie charts can only take a single series of data. The title of the chart will default to being the title of the series.

from openpyxl import Workbook

from openpyxl.chart import (
    PieChart,
    ProjectedPieChart,
    Reference
)
from openpyxl.chart.series import DataPoint

data = [
    ['Pie', 'Sold'],
    ['Apple', 50],
    ['Cherry', 30],
    ['Pumpkin', 10],
    ['Chocolate', 40],
]

wb = Workbook()
ws = wb.active

for row in data:
    ws.append(row)

pie = PieChart()
labels = Reference(ws, min_col=1, min_row=2, max_row=5)
data = Reference(ws, min_col=2, min_row=1, max_row=5)
pie.add_data(data, titles_from_data=True)
pie.set_categories(labels)
pie.title = "Pies sold by category"

# Cut the first slice out of the pie
slice = DataPoint(idx=0, explosion=20)
pie.series[0].data_points = [slice]

ws.add_chart(pie, "D1")


ws = wb.create_sheet(title="Projection")

data = [
    ['Page', 'Views'],
    ['Search', 95],
    ['Products', 4],
    ['Offers', 0.5],
    ['Sales', 0.5],
]

for row in data:
    ws.append(row)

projected_pie = ProjectedPieChart()
projected_pie.type = "pie"
projected_pie.splitType = "val" # split by value
labels = Reference(ws, min_col=1, min_row=2, max_row=5)
data = Reference(ws, min_col=2, min_row=1, max_row=5)
projected_pie.add_data(data, titles_from_data=True)
projected_pie.set_categories(labels)

ws.add_chart(projected_pie, "A10")

from copy import deepcopy
projected_bar = deepcopy(projected_pie)
projected_bar.type = "bar"
projected_bar.splitType = 'pos' # split by position

ws.add_chart(projected_bar, "A27")

wb.save("pie.xlsx")
"Sample pie chart"
Projected Pie Charts

Projected pie charts extract some slices from a pie chart and project them into a second pie or bar chart. This is useful when there are several smaller items in the data series. The chart can be split according to percent, val(ue) or pos(ition). If nothing is set then the application decides which to use. In addition custom splits can be defined.

"Sample pie chart with projections"
3D Pie Charts

Pie charts can also be created with a 3D effect.

from openpyxl import Workbook

from openpyxl.chart import (
    PieChart3D,
    Reference
)

data = [
    ['Pie', 'Sold'],
    ['Apple', 50],
    ['Cherry', 30],
    ['Pumpkin', 10],
    ['Chocolate', 40],
]

wb = Workbook()
ws = wb.active

for row in data:
    ws.append(row)

pie = PieChart3D()
labels = Reference(ws, min_col=1, min_row=2, max_row=5)
data = Reference(ws, min_col=2, min_row=1, max_row=5)
pie.add_data(data, titles_from_data=True)
pie.set_categories(labels)
pie.title = "Pies sold by category"


ws.add_chart(pie, "D1")

wb.save("pie3D.xlsx")
"Sample 3D pie chart"
Gradient Pie Charts

Pie charts can also be created with gradient series.

from openpyxl import Workbook

from openpyxl.chart import (
    PieChart,
    Reference
)
from openpyxl.chart.series import DataPoint
from openpyxl.chart.shapes import GraphicalProperties
from openpyxl.drawing.fill import (
    GradientFillProperties,
    GradientStop,
    LinearShadeProperties
)
from openpyxl.drawing.colors import SchemeColor

data = [
    ['Pie', 'Sold'],
    ['Apple', 50],
    ['Cherry', 30],
    ['Pumpkin', 10],
    ['Chocolate', 40],
]

wb = Workbook()
ws = wb.active

for row in data:
    ws.append(row)

pie = PieChart()
labels = Reference(ws, min_col=1, min_row=2, max_row=5)
data = Reference(ws, min_col=2, min_row=1, max_row=5)
pie.add_data(data, titles_from_data=True)
pie.set_categories(labels)
pie.title = "Pies sold by category"

# Cut the first slice out of the pie and apply a gradient to it
slice = DataPoint(
    idx=0,
    explosion=20,
    spPr=GraphicalProperties(
        gradFill=GradientFillProperties(
            gsLst=(
                GradientStop(
                    pos=0,
                    prstClr='blue'
                ),
                GradientStop(
                    pos=100000,
                    schemeClr=SchemeColor(
                        val='accent1',
                        lumMod=30000,
                        lumOff=70000
                    )
                )
            )
        )
    )
)
pie.series[0].data_points = [slice]

ws.add_chart(pie, "D1")

wb.save("pie.xlsx")
"Sampe gradient pie chart"
Doughnut Charts

Doughnut charts are similar to pie charts except that they use a ring instead of a circle. They can also plot several series of data as concentric rings.

from openpyxl import Workbook

from openpyxl.chart import (
    DoughnutChart,
    Reference,
    Series,
)
from openpyxl.chart.series import DataPoint

data = [
    ['Pie', 2014, 2015],
    ['Plain', 40, 50],
    ['Jam', 2, 10],
    ['Lime', 20, 30],
    ['Chocolate', 30, 40],
]

wb = Workbook()
ws = wb.active

for row in data:
    ws.append(row)

chart = DoughnutChart()
labels = Reference(ws, min_col=1, min_row=2, max_row=5)
data = Reference(ws, min_col=2, min_row=1, max_row=5)
chart.add_data(data, titles_from_data=True)
chart.set_categories(labels)
chart.title = "Doughnuts sold by category"
chart.style = 26

# Cut the first slice out of the doughnut
slices = [DataPoint(idx=i) for i in range(4)]
plain, jam, lime, chocolate = slices
chart.series[0].data_points = slices
plain.graphicalProperties.solidFill = "FAE1D0"
jam.graphicalProperties.solidFill = "BB2244"
lime.graphicalProperties.solidFill = "22DD22"
chocolate.graphicalProperties.solidFill = "61210B"
chocolate.explosion = 10

ws.add_chart(chart, "E1")

from copy import deepcopy

chart2 = deepcopy(chart)
chart2.title = None
data = Reference(ws, min_col=3, min_row=1, max_row=5)
series2 = Series(data, title_from_data=True)
series2.data_points = slices
chart2.series.append(series2)

ws.add_chart(chart2, "E17")

wb.save("doughnut.xlsx")
"Sample doughnut charts"
Radar Charts

Data that is arranged in columns or rows on a worksheet can be plotted in a radar chart. Radar charts compare the aggregate values of multiple data series. It is effectively a projection of an area chart on a circular x-axis.

There are two types of radar chart: standard, where the area is marked with a line; and filled, where the whole area is filled. The additional type “marker” has no effect. If markers are desired these can be set for the relevant series.

from openpyxl import Workbook
from openpyxl.chart import (
    RadarChart,
    Reference,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Month', "Bulbs", "Seeds", "Flowers", "Trees & shrubs"],
    ['Jan', 0, 2500, 500, 0,],
    ['Feb', 0, 5500, 750, 1500],
    ['Mar', 0, 9000, 1500, 2500],
    ['Apr', 0, 6500, 2000, 4000],
    ['May', 0, 3500, 5500, 3500],
    ['Jun', 0, 0, 7500, 1500],
    ['Jul', 0, 0, 8500, 800],
    ['Aug', 1500, 0, 7000, 550],
    ['Sep', 5000, 0, 3500, 2500],
    ['Oct', 8500, 0, 2500, 6000],
    ['Nov', 3500, 0, 500, 5500],
    ['Dec', 500, 0, 100, 3000 ],
]

for row in rows:
    ws.append(row)

chart = RadarChart()
chart.type = "filled"
labels = Reference(ws, min_col=1, min_row=2, max_row=13)
data = Reference(ws, min_col=2, max_col=5, min_row=1, max_row=13)
chart.add_data(data, titles_from_data=True)
chart.set_categories(labels)
chart.style = 26
chart.title = "Garden Centre Sales"
chart.y_axis.delete = True

ws.add_chart(chart, "A17")

wb.save("radar.xlsx")
"Sample radar chart"
Stock Charts

Data that is arranged in columns or rows in a specific order on a worksheet can be plotted in a stock chart. As its name implies, a stock chart is most often used to illustrate the fluctuation of stock prices. However, this chart may also be used for scientific data. For example, you could use a stock chart to indicate the fluctuation of daily or annual temperatures. You must organize your data in the correct order to create stock charts.

The way stock chart data is organized in the worksheet is very important. For example, to create a simple high-low-close stock chart, you should arrange your data with High, Low, and Close entered as column headings, in that order.

Although stock charts are a distinct type, the various types are just shortcuts for particular formatting options:

  • high-low-close is essentially a line chart with no lines and the marker set to XYZ. It also sets hiLoLines to True
  • open-high-low-close is the same as a high-low-close chart with the marker for each data point set to XZZ and upDownLines.

Volume can be added by combining the stock chart with a bar chart for the volume.

from datetime import date

from openpyxl import Workbook

from openpyxl.chart import (
    BarChart,
    StockChart,
    Reference,
    Series,
)
from openpyxl.chart.axis import DateAxis, ChartLines
from openpyxl.chart.updown_bars import UpDownBars

wb = Workbook()
ws = wb.active

rows = [
   ['Date',      'Volume','Open', 'High', 'Low', 'Close'],
   ['2015-01-01', 20000,    26.2, 27.20, 23.49, 25.45,  ],
   ['2015-01-02', 10000,    25.45, 25.03, 19.55, 23.05, ],
   ['2015-01-03', 15000,    23.05, 24.46, 20.03, 22.42, ],
   ['2015-01-04', 2000,     22.42, 23.97, 20.07, 21.90, ],
   ['2015-01-05', 12000,    21.9, 23.65, 19.50, 21.51,  ],
]

for row in rows:
    ws.append(row)

# High-low-close
c1 = StockChart()
labels = Reference(ws, min_col=1, min_row=2, max_row=6)
data = Reference(ws, min_col=4, max_col=6, min_row=1, max_row=6)
c1.add_data(data, titles_from_data=True)
c1.set_categories(labels)
for s in c1.series:
    s.graphicalProperties.line.noFill = True
# marker for close
s.marker.symbol = "dot"
s.marker.size = 5
c1.title = "High-low-close"
c1.hiLowLines = ChartLines()

# Excel is broken and needs a cache of values in order to display hiLoLines :-/
from openpyxl.chart.data_source import NumData, NumVal
pts = [NumVal(idx=i) for i in range(len(data) - 1)]
cache = NumData(pt=pts)
c1.series[-1].val.numRef.numCache = cache

ws.add_chart(c1, "A10")

# Open-high-low-close
c2 = StockChart()
data = Reference(ws, min_col=3, max_col=6, min_row=1, max_row=6)
c2.add_data(data, titles_from_data=True)
c2.set_categories(labels)
for s in c2.series:
    s.graphicalProperties.line.noFill = True
c2.hiLowLines = ChartLines()
c2.upDownBars = UpDownBars()
c2.title = "Open-high-low-close"

# add dummy cache
c2.series[-1].val.numRef.numCache = cache

ws.add_chart(c2, "G10")

# Create bar chart for volume

bar = BarChart()
data =  Reference(ws, min_col=2, min_row=1, max_row=6)
bar.add_data(data, titles_from_data=True)
bar.set_categories(labels)

from copy import deepcopy

# Volume-high-low-close
b1 = deepcopy(bar)
c3 = deepcopy(c1)
c3.y_axis.majorGridlines = None
c3.y_axis.title = "Price"
b1.y_axis.axId = 20
b1.z_axis = c3.y_axis
b1.y_axis.crosses = "max"
b1 += c3

c3.title = "High low close volume"

ws.add_chart(b1, "A27")

## Volume-open-high-low-close
b2 = deepcopy(bar)
c4 = deepcopy(c2)
c4.y_axis.majorGridlines = None
c4.y_axis.title = "Price"
b2.y_axis.axId = 20
b2.z_axis = c4.y_axis
b2.y_axis.crosses = "max"
b2 += c4

ws.add_chart(b2, "G27")

wb.save("stock.xlsx")

Warning

Due to a bug in Excel high-low lines will only be shown if at least one of the data series has some dummy values. This can be done with the following hack:

from openpyxl.chart.data_source import NumData, NumVal
pts = [NumVal(idx=i) for i in range(len(data) - 1)]
cache = NumData(pt=pts)
c1.series[-1].val.numRef.numCache = cache
"Sample stock charts"
Surface charts

Data that is arranged in columns or rows on a worksheet can be plotted in a surface chart. A surface chart is useful when you want to find optimum combinations between two sets of data. As in a topographic map, colors and patterns indicate areas that are in the same range of values.

By default all surface charts are 3D. 2D wireframe and contour charts are created by setting the rotation and perspective.

from openpyxl import Workbook
from openpyxl.chart import (
    SurfaceChart,
    SurfaceChart3D,
    Reference,
    Series,
)
from openpyxl.chart.axis import SeriesAxis

wb = Workbook()
ws = wb.active

data = [
    [None, 10, 20, 30, 40, 50,],
    [0.1, 15, 65, 105, 65, 15,],
    [0.2, 35, 105, 170, 105, 35,],
    [0.3, 55, 135, 215, 135, 55,],
    [0.4, 75, 155, 240, 155, 75,],
    [0.5, 80, 190, 245, 190, 80,],
    [0.6, 75, 155, 240, 155, 75,],
    [0.7, 55, 135, 215, 135, 55,],
    [0.8, 35, 105, 170, 105, 35,],
    [0.9, 15, 65, 105, 65, 15],
]

for row in data:
    ws.append(row)


c1 = SurfaceChart()
ref = Reference(ws, min_col=2, max_col=6, min_row=1, max_row=10)
labels = Reference(ws, min_col=1, min_row=2, max_row=10)
c1.add_data(ref, titles_from_data=True)
c1.set_categories(labels)
c1.title = "Contour"

ws.add_chart(c1, "A12")

from copy import deepcopy

# wireframe
c2 = deepcopy(c1)
c2.wireframe = True
c2.title = "2D Wireframe"

ws.add_chart(c2, "G12")

# 3D Surface
c3 = SurfaceChart3D()
c3.add_data(ref, titles_from_data=True)
c3.set_categories(labels)
c3.title = "Surface"

ws.add_chart(c3, "A29")

c4 = deepcopy(c3)
c4.wireframe = True
c4.title = "3D Wireframe"

ws.add_chart(c4, "G29")

wb.save("surface.xlsx")
"Sample surface charts"
Creating a chart

Charts are composed of at least one series of one or more data points. Series themselves are comprised of references to cell ranges.

>>> from openpyxl import Workbook
>>> wb = Workbook()
>>> ws = wb.active
>>> for i in range(10):
...     ws.append([i])
>>>
>>> from openpyxl.chart import BarChart, Reference, Series
>>> values = Reference(ws, min_col=1, min_row=1, max_col=1, max_row=10)
>>> chart = BarChart()
>>> chart.add_data(values)
>>> ws.add_chart(chart, "E15")
>>> wb.save("SampleChart.xlsx")

By default the top-left corner of a chart is anchored to cell E15 and the size is 15 x 7.5 cm (approximately 5 columns by 14 rows). This can be changed by setting the anchor, width and height properties of the chart. The actual size will depend on operating system and device. Other anchors are possible; see openpyxl.drawing.spreadsheet_drawing for further information.

Working with axes
Axis Limits and Scale
Minima and Maxima

Axis minimum and maximum values can be set manually to display specific regions on a chart.

from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

ws.append(['X', '1/X'])
for x in range(-10, 11):
    if x:
        ws.append([x, 1.0 / x])

chart1 = ScatterChart()
chart1.title = "Full Axes"
chart1.x_axis.title = 'x'
chart1.y_axis.title = '1/x'
chart1.legend = None

chart2 = ScatterChart()
chart2.title = "Clipped Axes"
chart2.x_axis.title = 'x'
chart2.y_axis.title = '1/x'
chart2.legend = None

chart2.x_axis.scaling.min = 0
chart2.y_axis.scaling.min = 0
chart2.x_axis.scaling.max = 11
chart2.y_axis.scaling.max = 1.5

x = Reference(ws, min_col=1, min_row=2, max_row=22)
y = Reference(ws, min_col=2, min_row=2, max_row=22)
s = Series(y, xvalues=x)
chart1.append(s)
chart2.append(s)

ws.add_chart(chart1, "C1")
ws.add_chart(chart2, "C15")

wb.save("minmax.xlsx")
"Sample charts with examples of axis clipping"

Note

In some cases such as the one shown, setting the axis limits is effectively equivalent to displaying a sub-range of the data. For large datasets, rendering of scatter plots (and possibly others) will be much faster when using subsets of the data rather than axis limits in both Excel and Open/Libre Office.

Logarithmic Scaling

Both the x- and y-axes can be scaled logarithmically. The base of the logarithm can be set to any valid float. If the x-axis is scaled logarithmically, negative values in the domain will be discarded.

from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)
import math

wb = Workbook()
ws = wb.active

ws.append(['X', 'Gaussian'])
for i, x in enumerate(range(-10, 11)):
    ws.append([x, "=EXP(-(($A${row}/6)^2))".format(row = i + 2)])

chart1 = ScatterChart()
chart1.title = "No Scaling"
chart1.x_axis.title = 'x'
chart1.y_axis.title = 'y'
chart1.legend = None

chart2 = ScatterChart()
chart2.title = "X Log Scale"
chart2.x_axis.title = 'x (log10)'
chart2.y_axis.title = 'y'
chart2.legend = None
chart2.x_axis.scaling.logBase = 10

chart3 = ScatterChart()
chart3.title = "Y Log Scale"
chart3.x_axis.title = 'x'
chart3.y_axis.title = 'y (log10)'
chart3.legend = None
chart3.y_axis.scaling.logBase = 10

chart4 = ScatterChart()
chart4.title = "Both Log Scale"
chart4.x_axis.title = 'x (log10)'
chart4.y_axis.title = 'y (log10)'
chart4.legend = None
chart4.x_axis.scaling.logBase = 10
chart4.y_axis.scaling.logBase = 10

chart5 = ScatterChart()
chart5.title = "Log Scale Base e"
chart5.x_axis.title = 'x (ln)'
chart5.y_axis.title = 'y (ln)'
chart5.legend = None
chart5.x_axis.scaling.logBase = math.e
chart5.y_axis.scaling.logBase = math.e

x = Reference(ws, min_col=1, min_row=2, max_row=22)
y = Reference(ws, min_col=2, min_row=2, max_row=22)
s = Series(y, xvalues=x)
chart1.append(s)
chart2.append(s)
chart3.append(s)
chart4.append(s)
chart5.append(s)

ws.add_chart(chart1, "C1")
ws.add_chart(chart2, "I1")
ws.add_chart(chart3, "C15")
ws.add_chart(chart4, "I15")
ws.add_chart(chart5, "F30")

wb.save("log.xlsx")

This produces five charts that look something like this:

"Sample charts with examples of axis log scaling"

The first four charts show the same data unscaled, scaled logarithmically in each axis and in both axes, with the logarithm base set to 10. The final chart shows the same data with both axes scaled, but the base of the logarithm set to e.

Axis Orientation

Axes can be displayed “normally” or in reverse. Axis orientation is controlled by the scaling orientation property, which can have a value of either 'minMax' for normal orientation or 'maxMin' for reversed.

from openpyxl import Workbook
from openpyxl.chart import (
    ScatterChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

ws["A1"] = "Archimedean Spiral"
ws.append(["T", "X", "Y"])
for i, t in enumerate(range(100)):
    ws.append([t / 16.0, "=$A${row}*COS($A${row})".format(row = i + 3),
                         "=$A${row}*SIN($A${row})".format(row = i + 3)])

chart1 = ScatterChart()
chart1.title = "Default Orientation"
chart1.x_axis.title = 'x'
chart1.y_axis.title = 'y'
chart1.legend = None

chart2 = ScatterChart()
chart2.title = "Flip X"
chart2.x_axis.title = 'x'
chart2.y_axis.title = 'y'
chart2.legend = None
chart2.x_axis.scaling.orientation = "maxMin"
chart2.y_axis.scaling.orientation = "minMax"

chart3 = ScatterChart()
chart3.title = "Flip Y"
chart3.x_axis.title = 'x'
chart3.y_axis.title = 'y'
chart3.legend = None
chart3.x_axis.scaling.orientation = "minMax"
chart3.y_axis.scaling.orientation = "maxMin"

chart4 = ScatterChart()
chart4.title = "Flip Both"
chart4.x_axis.title = 'x'
chart4.y_axis.title = 'y'
chart4.legend = None
chart4.x_axis.scaling.orientation = "maxMin"
chart4.y_axis.scaling.orientation = "maxMin"

x = Reference(ws, min_col=2, min_row=2, max_row=102)
y = Reference(ws, min_col=3, min_row=2, max_row=102)
s = Series(y, xvalues=x)
chart1.append(s)
chart2.append(s)
chart3.append(s)
chart4.append(s)

ws.add_chart(chart1, "D1")
ws.add_chart(chart2, "J1")
ws.add_chart(chart3, "D15")
ws.add_chart(chart4, "J15")

wb.save("orientation.xlsx")

This produces four charts with the axes in each possible combination of orientations that look something like this:

"Sample charts with different axis orientations"
Adding a second axis

Adding a second axis actually involves creating a second chart that shares a common x-axis with the first chart but has a separate y-axis.

from openpyxl import Workbook
from openpyxl.chart import (
    LineChart,
    BarChart,
    Reference,
    Series,
)

wb = Workbook()
ws = wb.active

rows = [
    ['Aliens', 2, 3, 4, 5, 6, 7],
    ['Humans', 10, 40, 50, 20, 10, 50],
]

for row in rows:
    ws.append(row)

c1 = BarChart()
v1 = Reference(ws, min_col=1, min_row=1, max_col=7)
c1.add_data(v1, titles_from_data=True, from_rows=True)

c1.x_axis.title = 'Days'
c1.y_axis.title = 'Aliens'
c1.y_axis.majorGridlines = None
c1.title = 'Survey results'


# Create a second chart
c2 = LineChart()
v2 = Reference(ws, min_col=1, min_row=2, max_col=7)
c2.add_data(v2, titles_from_data=True, from_rows=True)
c2.y_axis.axId = 200
c2.y_axis.title = "Humans"

# Display y-axis of the second chart on the right by setting it to cross the x-axis at its maximum
c1.y_axis.crosses = "max"
c1 += c2

ws.add_chart(c1, "D4")

wb.save("secondary.xlsx")

This produces a combined line and bar chart looking something like this:

"Sample chart with a second y-axis"
Change the chart layout
Changing the layout of plot area and legend

The layout of the chart within the canvas can be set by using the layout property of an instance of a layout class.

Chart layout
Size and position

The chart can be positioned within its container. x and y adjust position, w and h adjust the size . The units are proportions of the container. A chart cannot be positioned outside of its container and the width and height are the dominant constraints: if x + w > 1, then x = 1 - w.

x is the horizontal position from the left
y is the vertical position from the top
h is the height of the chart relative to its container
w is the width of the box
Mode

In addition to the size and position, the mode for the relevant attribute can also be set to either factor or edge. Factor is the default:

layout.xMode = edge
Target

The layoutTarget can be set to outer or inner. The default is outer:

layout.layoutTarget = inner
Legend layout

The position of the legend can be controlled either by setting its position: r, l, t, b, and tr, for right, left, top, bottom and top right respectively. The default is r.

legend.position = 'tr'

or applying a manual layout:

legend.layout = ManualLayout()
from openpyxl import Workbook, load_workbook
from openpyxl.chart import ScatterChart, Series, Reference
from openpyxl.chart.layout import Layout, ManualLayout

wb = Workbook()
ws = wb.active

rows = [
    ['Size', 'Batch 1', 'Batch 2'],
    [2, 40, 30],
    [3, 40, 25],
    [4, 50, 30],
    [5, 30, 25],
    [6, 25, 35],
    [7, 20, 40],
]

for row in rows:
    ws.append(row)

ch1 = ScatterChart()
xvalues = Reference(ws, min_col=1, min_row=2, max_row=7)
for i in range(2, 4):
    values = Reference(ws, min_col=i, min_row=1, max_row=7)
    series = Series(values, xvalues, title_from_data=True)
    ch1.series.append(series)


ch1.title = "Default layout"
ch1.style = 13
ch1.x_axis.title = 'Size'
ch1.y_axis.title = 'Percentage'
ch1.legend.position = 'r'

ws.add_chart(ch1, "B10")

from copy import deepcopy

# Half-size chart, bottom right
ch2 = deepcopy(ch1)
ch2.title = "Manual chart layout"
ch2.legend.position = "tr"
ch2.layout=Layout(
    manualLayout=ManualLayout(
        x=0.25, y=0.25,
        h=0.5, w=0.5,
    )
)
ws.add_chart(ch2, "H10")

# Half-size chart, centred
ch3 = deepcopy(ch1)
ch3.layout = Layout(
    ManualLayout(
    x=0.25, y=0.25,
    h=0.5, w=0.5,
    xMode="edge",
    yMode="edge",
    )
)
ch3.title = "Manual chart layout, edge mode"
ws.add_chart(ch3, "B27")

# Manually position the legend bottom left
ch4 = deepcopy(ch1)
ch4.title = "Manual legend layout"
ch4.legend.layout = Layout(
    manualLayout=ManualLayout(
        yMode='edge',
        xMode='edge',
        x=0, y=0.9,
        h=0.1, w=0.5
    )
)

ws.add_chart(ch4, "H27")

wb.save("chart_layout.xlsx")

This produces four charts illustrating various possibilities:

"Different chart and legend layouts"
Styling charts
Adding Patterns

Whole data series and individual data points can be extensively styled through the graphicalProperties. Getting things just right may take some time.

from openpyxl import Workbook
from openpyxl.chart import BarChart, Reference
from openpyxl.chart.marker import DataPoint

from openpyxl.drawing.fill import PatternFillProperties, ColorChoice

wb = Workbook()
ws = wb.active

rows = [
    ("Sample",),
    (1,),
    (2,),
    (3,),
    (2,),
    (3,),
    (3,),
    (1,),
    (2,),
]

for r in rows:
    ws.append(r)


c = BarChart()
data = Reference(ws, min_col=1, min_row=1, max_row=8)
c.add_data(data, titles_from_data=True)
c.title = "Chart with patterns"

# set a pattern for the whole series
series = c.series[0]
fill =  PatternFillProperties(prst="pct5")
fill.foreground = ColorChoice(prstClr="red")
fill.background = ColorChoice(prstClr="blue")
series.graphicalProperties.pattFill = fill

# set a pattern for a 6th data point (0-indexed)
pt = DataPoint(idx=5)
pt.graphicalProperties.pattFill = PatternFillProperties(prst="ltHorz")
series.dPt.append(pt)

ws.add_chart(c, "C1")

wb.save("pattern.xlsx")
"Sample bar chart with patterned columns"
Advanced charts

Charts can be combined to create new charts:

Gauge Charts

Gauge charts combine a pie chart and a doughnut chart to create a “gauge”. The first chart is a doughnut chart with four slices. The first three slices correspond to the colours of the gauge; the fourth slice, which is half of the doughnut, is made invisible.

A pie chart containing three slices is added. The first and third slice are invisible so that the second slice can act as the needle on the gauge.

The effects are done using the graphical properties of individual data points in a data series.

from openpyxl import Workbook

from openpyxl.chart import PieChart, DoughnutChart, Series, Reference
from openpyxl.chart.series import DataPoint


data = [
    ["Donut", "Pie"],
    [25, 75],
    [50, 1],
    [25, 124],
    [100],
]

# based on http://www.excel-easy.com/examples/gauge-chart.html

wb = Workbook()
ws = wb.active
for row in data:
    ws.append(row)

# First chart is a doughnut chart
c1 = DoughnutChart(firstSliceAng=270, holeSize=50)
c1.title = "Code coverage"
c1.legend = None

ref = Reference(ws, min_col=1, min_row=2, max_row=5)
s1 = Series(ref, title_from_data=False)

slices = [DataPoint(idx=i) for i in range(4)]
slices[0].graphicalProperties.solidFill = "FF3300" # red
slices[1].graphicalProperties.solidFill = "FCF305" # yellow
slices[2].graphicalProperties.solidFill = "1FB714" # green
slices[3].graphicalProperties.noFill = True # invisible

s1.data_points = slices
c1.series = [s1]

# Second chart is a pie chart
c2 = PieChart(firstSliceAng=270)
c2.legend = None

ref = Reference(ws, min_col=2, min_row=2, max_col=2, max_row=4)
s2 = Series(ref, title_from_data=False)

slices = [DataPoint(idx=i) for i in range(3)]
slices[0].graphicalProperties.noFill = True # invisible
slices[1].graphicalProperties.solidFill = "000000" # black needle
slices[2].graphicalProperties.noFill = True # invisible
s2.data_points = slices
c2.series = [s2]

c1 += c2 # combine charts

ws.add_chart(c1, "D1")

wb.save("gauge.xlsx")
"Sample gauge chart"
Using chartsheets

Charts can be added to special worksheets called chartsheets:

Chartsheets

Chartsheets are special worksheets which only contain charts. All the data for the chart must be on a different worksheet.

from openpyxl import Workbook

from openpyxl.chart import PieChart, Reference, Series

wb = Workbook()
ws = wb.active
cs = wb.create_chartsheet()

rows = [
    ["Bob", 3],
    ["Harry", 2],
    ["James", 4],
]

for row in rows:
    ws.append(row)


chart = PieChart()
labels = Reference(ws, min_col=1, min_row=1, max_row=3)
data = Reference(ws, min_col=2, min_row=1, max_row=3)
chart.series = (Series(data),)
chart.title = "PieChart"

cs.add_chart(chart)

wb.save("demo.xlsx")
"Sample chartsheet"

By default in Microsoft Excel, charts are chartsheets are designed to fit the page format of the active printer. By default in openpyxl, charts are designed to fit window in which they’re displayed. You can flip between these using the zoomToFit attribute of the active view, typically cs.sheetViews.sheetView[0].zoomToFit

Positioning charts

Position charts using anchors:

Positioning Charts with Anchors

You can position charts using one of three different kinds of anchor:

  • OneCell – where the top-left of a chart is anchored to a single cell. This is the default for openpyxl and corresponds to the layout option “Move but don’t size with cells”.
  • TwoCell – where the top-left of a chart is anchored to one cell, and the bottom-right to another cell. This corresponds to the layout option “Move and size with cells”.
  • Absolute – where the chart is placed relative to the worksheet’s top-left corner and not any particular cell.

You can change anchors quite easily on a chart like this. Let’s assume we have created a bar chart using the sample code:

from openpyxl import Workbook
from openpyxl.chart import BarChart, Series, Reference

wb = Workbook(write_only=True)
ws = wb.create_sheet()

rows = [
    ('Number', 'Batch 1', 'Batch 2'),
    (2, 10, 30),
    (3, 40, 60),
    (4, 50, 70),
    (5, 20, 10),
    (6, 10, 40),
    (7, 50, 30),
]


for row in rows:
    ws.append(row)


chart1 = BarChart()
chart1.type = "col"
chart1.style = 10
chart1.title = "Bar Chart"
chart1.y_axis.title = 'Test number'
chart1.x_axis.title = 'Sample length (mm)'

data = Reference(ws, min_col=2, min_row=1, max_row=7, max_col=3)
cats = Reference(ws, min_col=1, min_row=2, max_row=7)
chart1.add_data(data, titles_from_data=True)
chart1.set_categories(cats)
chart1.shape = 4
ws.add_chart(chart1, "A10")

from copy import deepcopy

chart2 = deepcopy(chart1)
chart2.style = 11
chart2.type = "bar"
chart2.title = "Horizontal Bar Chart"

ws.add_chart(chart2, "G10")


chart3 = deepcopy(chart1)
chart3.type = "col"
chart3.style = 12
chart3.grouping = "stacked"
chart3.overlap = 100
chart3.title = 'Stacked Chart'

ws.add_chart(chart3, "A27")


chart4 = deepcopy(chart1)
chart4.type = "bar"
chart4.style = 13
chart4.grouping = "percentStacked"
chart4.overlap = 100
chart4.title = 'Percent Stacked Chart'

ws.add_chart(chart4, "G27")

wb.save("bar.xlsx")

Let’s take the first chart. Instead of anchoring it to A10, we want it to keep it with our table of data, say A9 to C20. We can do this by creating a TwoCellAnchor for those two cells.:

from openpyxl.drawing.spreadsheet_drawing import TwoCellAnchor

anchor = TwoCellAnchor()
anchor._from.col = 0 #A
anchor._from.row = 8 # row 9, using 0-based indexing
anchor.to.col = 2 #C
anchor.to.row = 19 # row 20

chart.anchor = anchor

You can also use this to change the anchors of existing charts.

Advanced chart formatting

Use graphical properties for advanced chart formatting:

Advanced Options with Graphical Properties

Many advanced options require using the Graphical Properties of OOXML. This is a much more abstract API than the chart API itself and may require considerable studying of the OOXML specification to get right. It is often unavoidable to look at the XML source of some charts you’ve made. However, as openpyxl tries very hard to implement the OOXML specification correctly, you should be able to do most things quite easily. To things easier to read, openpyxl includes some aliases for some of the more obscure element or attribute names, eg. GraphicalProperties for `spPr or line for line.

Make the chart background transparent
from openpyxl.chart.shapes import GraphicalProperties
chart.graphical_properties = GraphicalProperties()
chart.graphical_properties.noFill = True
Remove the border from a chart
from openpyxl.chart.shapes import GraphicalProperties
chart.graphical_properties = GraphicalProperties()
chart.graphical_properties.line.noFill = True
chart.graphical_properties.line.prstDash = None
Reusing XML

Due to the high degree of abstraction, DrawingML is used in different office programs, it can be tedious and frustrating to set the relevant properties for the desired effect. Fortunately, because openpyxl is very close to the specification, it is often possible to use XML from source. For example, adding a single, formatted data label to a series.

xml = """
<txPr>
  <a:bodyPr wrap="square" lIns="38100" tIns="19050" rIns="38100" bIns="19050" anchor="ctr" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
    <a:spAutoFit />
  </a:bodyPr>
  <a:lstStyle xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" />
  <a:p xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
    <a:pPr>
      <a:defRPr>
        <a:solidFill>
          <a:srgbClr val="0070C0" />
        </a:solidFill>
      </a:defRPr>
    </a:pPr>
    <a:endParaRPr lang="de-DE" />
  </a:p>
</txPr>
"""

from openpyxl.chart.text import RichText
from openpyxl.xml.functions import fromstring

xml = fromstring(txt)
text_props = RichText.from_tree(xml)

# Assuming that this is for the third data series for a chart and we want to add a label below the fourth data point.

highlight = chart.series[2]
highlight.graphicalProperties.line.prstDash = "solid"
highlight.graphicalProperties.ln.solidFill = "0070C0"
highlight.graphicalProperties.line.width = 40000 # make the line thicker than normal
highlight.dLbls = DataLabelList()
highlight = DataLabel(idx=3, showSerName=True, dLblPos="b", txPr=text_props)
highlight.dLbls.dLbl.append(label)
"Highlighting a single value on a single series"

Working with Images

Inserting an image
>>> from openpyxl import Workbook
>>> from openpyxl.drawing.image import Image
>>>
>>> wb = Workbook()
>>> ws = wb.active
>>> ws['A1'] = 'You should see three logos below'
>>>
>>> # create an image
>>> img = Image('logo.png')
>>>
>>> # add to worksheet and anchor next to cells
>>> ws.add_image(img, 'A1')
>>> wb.save('logo.xlsx')

Working with Pandas and NumPy

openpyxl is able to work with the popular libraries Pandas and NumPy

NumPy Support

openpyxl has builtin support for the NumPy types float, integer and boolean. DateTimes are supported using the Pandas’ Timestamp type.

Working with Pandas Dataframes

The openpyxl.utils.dataframe.dataframe_to_rows() function provides a simple way to work with Pandas Dataframes:

from openpyxl.utils.dataframe import dataframe_to_rows
wb = Workbook()
ws = wb.active

for r in dataframe_to_rows(df, index=True, header=True):
    ws.append(r)

While Pandas itself supports conversion to Excel, this gives client code additional flexibility including the ability to stream dataframes straight to files.

To convert a dataframe into a worksheet highlighting the header and index:

wb = Workbook()
ws = wb.active

for r in dataframe_to_rows(df, index=True, header=True):
    ws.append(r)

for cell in ws['A'] + ws[1]:
    cell.style = 'Pandas'

wb.save("pandas_openpyxl.xlsx")

Alternatively, if you just want to convert the data you can use write-only mode:

from openpyxl.cell.cell import WriteOnlyCell
wb = Workbook(write_only=True)
ws = wb.create_sheet()

cell = WriteOnlyCell(ws)
cell.style = 'Pandas'

 def format_first_row(row, cell):

    for c in row:
        cell.value = c
        yield cell

rows = dataframe_to_rows(df)
first_row = format_first_row(next(rows), cell)
ws.append(first_row)

for row in rows:
    row = list(row)
    cell.value = row[0]
    row[0] = cell
    ws.append(row)

wb.save("openpyxl_stream.xlsx")

This code will work just as well with a standard workbook.

Converting a worksheet to a Dataframe

To convert a worksheet to a Dataframe you can use the values property. This is very easy if the worksheet has no headers or indices:

df = DataFrame(ws.values)

If the worksheet does have headers or indices, such as one created by Pandas, then a little more work is required:

from itertools import islice
data = ws.values
cols = next(data)[1:]
data = list(data)
idx = [r[0] for r in data]
data = (islice(r, 1, None) for r in data)
df = DataFrame(data, index=idx, columns=cols)

Optimised Modes

Read-only mode

Sometimes, you will need to open or write extremely large XLSX files, and the common routines in openpyxl won’t be able to handle that load. Fortunately, there are two modes that enable you to read and write unlimited amounts of data with (near) constant memory consumption.

Introducing openpyxl.worksheet._read_only.ReadOnlyWorksheet:

from openpyxl import load_workbook
wb = load_workbook(filename='large_file.xlsx', read_only=True)
ws = wb['big_data']

for row in ws.rows:
    for cell in row:
        print(cell.value)

# Close the workbook after reading
wb.close()

Warning

  • openpyxl.worksheet._read_only.ReadOnlyWorksheet is read-only
  • Unlike a normal workbook, a read-only workbook will use lazy loading. The workbook must be explicitly closed with the close() method.

Cells returned are not regular openpyxl.cell.cell.Cell but openpyxl.cell._read_only.ReadOnlyCell.

Worksheet dimensions

Read-only mode relies on applications and libraries that created the file providing correct information about the worksheets, specifically the used part of it, known as the dimensions. Some applications set this incorrectly. You can check the apparent dimensions of a worksheet using ws.calculate_dimension(). If this returns a range that you know is incorrect, say A1:A1 then simply resetting the max_row and max_column attributes should allow you to work with the file:

ws.reset_dimensions()
Write-only mode

Here again, the regular openpyxl.worksheet.worksheet.Worksheet has been replaced by a faster alternative, the openpyxl.worksheet._write_only.WriteOnlyWorksheet. When you want to dump large amounts of data make sure you have lxml installed.

>>> from openpyxl import Workbook
>>> wb = Workbook(write_only=True)
>>> ws = wb.create_sheet()
>>>
>>> # now we'll fill it with 100 rows x 200 columns
>>>
>>> for irow in range(100):
...     ws.append(['%d' % i for i in range(200)])
>>> # save the file
>>> wb.save('new_big_file.xlsx') # doctest: +SKIP

If you want to have cells with styles or comments then use a openpyxl.cell.WriteOnlyCell()

>>> from openpyxl import Workbook
>>> wb = Workbook(write_only = True)
>>> ws = wb.create_sheet()
>>> from openpyxl.cell import WriteOnlyCell
>>> from openpyxl.comments import Comment
>>> from openpyxl.styles import Font
>>> cell = WriteOnlyCell(ws, value="hello world")
>>> cell.font = Font(name='Courier', size=36)
>>> cell.comment = Comment(text="A comment", author="Author's Name")
>>> ws.append([cell, 3.14, None])
>>> wb.save('write_only_file.xlsx')

This will create a write-only workbook with a single sheet, and append a row of 3 cells: one text cell with a custom font and a comment, a floating-point number, and an empty cell (which will be discarded anyway).

Warning

  • Unlike a normal workbook, a newly-created write-only workbook does not contain any worksheets; a worksheet must be specifically created with the create_sheet() method.
  • In a write-only workbook, rows can only be added with append(). It is not possible to write (or read) cells at arbitrary locations with cell() or iter_rows().
  • It is able to export unlimited amount of data (even more than Excel can handle actually), while keeping memory usage under 10Mb.
  • A write-only workbook can only be saved once. After that, every attempt to save the workbook or append() to an existing worksheet will raise an openpyxl.utils.exceptions.WorkbookAlreadySaved exception.
  • Everything that appears in the file before the actual cell data must be created before cells are added because it must written to the file before then. For example, freeze_panes should be set before cells are added.

Performance

openpyxl attempts to balance functionality and performance. Where in doubt, we have focused on functionality over optimisation: performance tweaks are easier once an API has been established. Memory use is fairly high in comparison with other libraries and applications and is approximately 50 times the original file size, e.g. 2.5 GB for a 50 MB Excel file. As many use cases involve either only reading or writing files, the Optimised Modes modes mean this is less of a problem.

Benchmarks

All benchmarks are synthetic and extremely dependent upon the hardware but they can nevertheless give an indication.

Write Performance

The benchmark code can be adjusted to use more sheets and adjust the proportion of data that is strings. Because the version of Python being used can also significantly affect performance, a driver script can also be used to test with different Python versions with a tox environment.

Performance is compared with the excellent alternative library xlsxwriter

Versions:
python: 3.6.9
openpyxl: 3.0.1
xlsxwriter: 1.2.5

Dimensions:
    Rows = 1000
    Cols = 50
    Sheets = 1
    Proportion text = 0.10

Times:
    xlsxwriter            :   0.59
    xlsxwriter (optimised):   0.54
    openpyxl              :   0.73
    openpyxl (optimised)  :   0.61


Versions:
python: 3.7.5
openpyxl: 3.0.1
xlsxwriter: 1.2.5

Dimensions:
    Rows = 1000
    Cols = 50
    Sheets = 1
    Proportion text = 0.10

Times:
    xlsxwriter            :   0.65
    xlsxwriter (optimised):   0.53
    openpyxl              :   0.70
    openpyxl (optimised)  :   0.63


Versions:
python: 3.8.0
openpyxl: 3.0.1
xlsxwriter: 1.2.5

Dimensions:
    Rows = 1000
    Cols = 50
    Sheets = 1
    Proportion text = 0.10

Times:
    xlsxwriter            :   0.54
    xlsxwriter (optimised):   0.50
    openpyxl              :   1.10
    openpyxl (optimised)  :   0.57
Read Performance

Performance is measured using a file provided with a previous bug report and compared with the older xlrd library. xlrd is primarily for the older BIFF file format of .XLS files but it does have limited support for XLSX.

The code for the benchmark shows the importance of choosing the right options when working with a file. In this case disabling external links stops openpyxl opening cached copies of the linked worksheets.

One major difference between the libraries is that openpyxl’s read-only mode opens a workbook almost immediately making it suitable for multiple processes, this also reduces memory use significantly. xlrd does also not automatically convert dates and times into Python datetimes, though it does annotate cells accordingly but to do this in client code significantly reduces performance.

Versions:
python: 3.6.9
xlread: 1.2.0
openpyxl: 3.0.1

openpyxl, read-only
    Workbook loaded 1.14s
    OptimizationData 23.17s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 23.92s
    Store days 100% 17.35s
    Total time 65.59s
    0 cells in total

Versions:
python: 3.7.5
xlread: 1.2.0
openpyxl: 3.0.1

openpyxl, read-only
    Workbook loaded 0.98s
    OptimizationData 21.35s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 20.70s
    Store days 100% 16.16s
    Total time 59.19s
    0 cells in total

Versions:
python: 3.8.0
xlread: 1.2.0
openpyxl: 3.0.1

openpyxl, read-only
    Workbook loaded 0.90s
    OptimizationData 19.58s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 19.35s
    Store days 100% 15.02s
    Total time 54.85s
    0 cells in total
Parallelisation

Reading worksheets is fairly CPU-intensive which limits any benefits to be gained by parallelisation. However, if you are mainly interested in dumping the contents of a workbook then you can use openpyxl’s read-only mode and open multiple instances of a workbook and take advantage of multiple CPUs.

Sample code using the same source file as for read performance shows that performance scales reasonably with only a slight overhead due to creating additional Python processes.

Development

If you find the openpyxl project intriguing and want to contribute a new awesome feature, fix a nasty bug or improve the documentation this section will guide you in setting up your development environment.

We will look into the coding standards and version control system workflows used, as well as cloning the openpyxl code to your local machine, setting up a virtual Python environment, running tests and building the documentation.

Getting the source

The source code of openpyxl is hosted on Heptapod as a Mercurial project which you can download using e.g. the GUI client SourceTree by Atlassian. If you prefer working with the command line you can use the following:

$ hg clone https://foss.heptapod.net/openpyxl/openpyxl
$ hg up 3.1

Please note that the default branch should never be used for development work. For bug fixes and minor patches you should base your work on the branch of the current release, e.g 3.1. New features should generally be based on the development branch of the next minor version. If in doubt get in touch with the openpyxl development team.

It is worthwhile to add an upstream remote reference to the original repository to update your fork with the latest changes, by adding to the ./hg/hgrc file the following:

[paths]
default = ...
openpyxl-master = https://foss.heptapod.net/openpyxl/openpyxl

You can then grab any new changes using:

$ hg pull openpyxl-master

After that you should create a virtual environment using virtualenv and install the project requirements and the project itself:

$ cd openpyxl
$ virtualenv openpyxl-env

Activate the environment using:

$ source bin/activate  # or ./openpyxl-env/Scripts/activate on Windows

Install the dev and prod dependencies and the package itself using:

(openpyxl-env) $ pip install -U -r requirements.txt
(openpyxl-env) $ pip install -e .
Running tests

Note that contributions to the project without tests will not be accepted.

We use pytest as the test runner with pytest-cov for coverage information and pytest-flakes for static code analysis.

To run all the tests you need to either execute:

(openpxyl-env) $ pytest -xrf openpyxl  # the flags will stop testing at the first error

Or use tox to run the tests on different Python versions and configurations:

$ tox openpyxl
Coverage

The goal is 100 % coverage for unit tests - data types and utility functions. Coverage information can be obtained using:

py.test --cov openpyxl
Organisation

Tests should be preferably at package / module level e.g openpyxl/cell. This makes testing and getting statistics for code under development easier:

py.test --cov openpyxl/cell openpyxl/cell
Checking XML

Use the openpyxl.tests.helper.compare_xml function to compare generated and expected fragments of XML.

Schema validation

When working on code to generate XML it is possible to validate that the generated XML conforms to the published specification. Note, this won’t necessarily guarantee that everything is fine but is preferable to reverse engineering!

Microsoft Tools

Along with the SDK, Microsoft also has a “Productivity Tool” for working with Office OpenXML.

This allows you to quickly inspect or compare whole Excel files. Unfortunately, validation errors contain many false positives. The tool also contain links to the specification and implementers’ notes.

File Support and Specifications

The primary aim of openpyxl is to support reading and writing Microsoft Excel 2010 files. These are zipped OOXML files that are specified by ECMA 376 and ISO 29500.

Where possible we try to support files generated by other libraries or programs, but can’t guarantee it, because often these do not strictly adhere to the above format.

Support of Python Versions

Python 3.6 and upwards are supported

Coding style

We orient ourselves at PEP-8 for the coding style, except when implementing attributes for round tripping. Despite that you are encouraged to use Python data conventions (boolean, None, etc.). Note exceptions from this convention in docstrings.

Contributing

Contributions in the form of pull requests are always welcome. Don’t forget to add yourself to the list of authors!

Branch naming convention

We use a “major.minor.patch” numbering system, ie. 3.1.2. Development branches are named after “major.minor” releases. In general, API change will only happen major releases but there will be exceptions. Always communicate API changes to the mailing list before making them. If you are changing an API try and an implement a fallback (with deprecation warning) for the old behaviour.

The “default branch” is used for releases and always has changes from a development branch merged in. It should never be the target for a pull request.

Pull Requests

Pull requests should be submitted to the current, unreleased development branch. Eg. if the current release is 3.1.2, pull requests should be made to the 3.1 branch. Exceptions are bug fixes to released versions which should be made to the relevant release branch and merged upstream into development.

Please use tox to test code for different submissions before making a pull request. This is especially important for picking up problems across Python versions.

Documentation

Remember to update the documentation when adding or changing features. Check that documentation is syntactically correct.:

tox -e doc
Benchmarking

Benchmarking and profiling are ongoing tasks. Contributions to these are very welcome as we know there is a lot to do.

Memory Use

There is a tox profile for long-running memory benchmarks using the memory_utils package.:

tox -e memory
Pympler

As openpyxl does not include any internal memory benchmarking tools, the python pympler package was used during the testing of styles to profile the memory usage in openpyxl.reader.excel.read_style_table():

# in openpyxl/reader/style.py
from pympler import muppy, summary

def read_style_table(xml_source):
  ...
  if cell_xfs is not None:  # ~ line 47
      initialState = summary.summarize(muppy.get_objects())  # Capture the initial state
      for index, cell_xfs_node in enumerate(cell_xfs_nodes):
         ...
         table[index] = new_style
      finalState = summary.summarize(muppy.get_objects())  # Capture the final state
      diff = summary.get_diff(initialState, finalState)  # Compare
      summary.print_(diff)

pympler.summary.print_() prints to the console a report of object memory usage, allowing the comparison of different methods and examination of memory usage. A useful future development would be to construct a benchmarking package to measure the performance of different components.

openpyxl package

Subpackages
openpyxl.cell package
Submodules
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]
openpyxl.cell.read_only module
class openpyxl.cell.read_only.EmptyCell[source]

Bases: object

alignment = None
border = None
data_type = 'n'
fill = None
font = None
is_date = False
number_format = None
value = None
class openpyxl.cell.read_only.ReadOnlyCell(sheet, row, column, value, data_type='n', style_id=0)[source]

Bases: object

alignment
border
column
column_letter
coordinate
data_type
fill
font
has_style
internal_value
is_date
number_format
parent
protection
row
style_array
value
openpyxl.cell.rich_text module

RichText definition

class openpyxl.cell.rich_text.CellRichText(*args)[source]

Bases: list

Represents a rich text string.

Initialize with a list made of pure strings or TextBlock elements Can index object to access or modify individual rich text elements it also supports the + and += operators between rich text strings There are no user methods for this class

operations which modify the string will generally call an optimization pass afterwards, that merges text blocks with identical formats, consecutive pure text strings, and remove empty strings and empty text blocks

append(arg)[source]

Append object to the end of the list.

as_list()[source]

Returns a list of the strings contained. The main reason for this is to make editing easier.

extend(arg)[source]

Extend list by appending elements from the iterable.

classmethod from_tree(node)[source]
class openpyxl.cell.rich_text.TextBlock(font, text)[source]

Bases: openpyxl.descriptors.Strict

Represents text string in a specific format

This class is used as part of constructing a rich text strings.

font

Values must be of type <class ‘openpyxl.cell.text.InlineFont’>

text

Values must be of type <class ‘str’>

openpyxl.cell.text module

Richtext definition

class openpyxl.cell.text.InlineFont(rFont=None, charset=None, family=None, b=None, i=None, strike=None, outline=None, shadow=None, condense=None, extend=None, color=None, sz=None, u=None, vertAlign=None, scheme=None)[source]

Bases: openpyxl.styles.fonts.Font

Font for inline text because, yes what you need are different objects with the same elements but different constraints.

b

Values must be of type <class ‘bool’>

charset

Values must be of type <class ‘int’>

color

Values must be of type <class ‘openpyxl.styles.colors.Color’>

condense

Values must be of type <class ‘bool’>

extend

Values must be of type <class ‘bool’>

family

Values must be of type <class ‘float’>

i

Values must be of type <class ‘bool’>

outline

Values must be of type <class ‘bool’>

rFont

Values must be of type <class ‘str’>

scheme

Value must be one of {‘major’, ‘minor’}

shadow

Values must be of type <class ‘bool’>

strike

Values must be of type <class ‘bool’>

sz

Values must be of type <class ‘float’>

tagname = 'RPrElt'
u

Value must be one of {‘single’, ‘singleAccounting’, ‘double’, ‘doubleAccounting’}

vertAlign

Value must be one of {‘superscript’, ‘baseline’, ‘subscript’}

class openpyxl.cell.text.PhoneticProperties(fontId=None, type=None, alignment=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alignment

Value must be one of {‘distributed’, ‘noControl’, ‘left’, ‘center’}

fontId

Values must be of type <class ‘int’>

tagname = 'phoneticPr'
type

Value must be one of {‘halfwidthKatakana’, ‘fullwidthKatakana’, ‘noConversion’, ‘Hiragana’}

class openpyxl.cell.text.PhoneticText(sb=None, eb=None, t=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

eb

Values must be of type <class ‘int’>

sb

Values must be of type <class ‘int’>

t

Values must be of type <class ‘str’>

tagname = 'rPh'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.cell.text.RichText(rPr=None, t=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

font

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rPr

Values must be of type <class ‘openpyxl.cell.text.InlineFont’>

t

Values must be of type <class ‘str’>

tagname = 'RElt'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.cell.text.Text(t=None, r=(), rPh=(), phoneticPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

PhoneticProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

content

Text stripped of all formatting

formatted

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

phonetic

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

phoneticPr

Values must be of type <class ‘openpyxl.cell.text.PhoneticProperties’>

plain

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

r

A sequence (list or tuple) that may only contain objects of the declared type

rPh

A sequence (list or tuple) that may only contain objects of the declared type

t

Values must be of type <class ‘str’>

tagname = 'text'
openpyxl.chart package
Submodules
openpyxl.chart.area_chart module
class openpyxl.chart.area_chart.AreaChart(axId=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.area_chart._AreaChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dropLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

grouping

Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'areaChart'
varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

class openpyxl.chart.area_chart.AreaChart3D(gapDepth=None, **kw)[source]

Bases: openpyxl.chart.area_chart.AreaChart

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dropLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

gapDepth

Values must be of type <class ‘float’>

grouping

Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'area3DChart'
varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

z_axis

Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>

openpyxl.chart.axis module
class openpyxl.chart.axis.ChartLines(spPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'chartLines'
class openpyxl.chart.axis.DateAxis(auto=None, lblOffset=None, baseTimeUnit=None, majorUnit=None, majorTimeUnit=None, minorUnit=None, minorTimeUnit=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.axis.TextAxis

auto

Values must be of type <class ‘bool’>

axId

Values must be of type <class ‘int’>

axPos

Value must be one of {‘r’, ‘t’, ‘b’, ‘l’}

baseTimeUnit

Value must be one of {‘months’, ‘years’, ‘days’}

crossAx

Values must be of type <class ‘int’>

crosses

Value must be one of {‘min’, ‘max’, ‘autoZero’}

crossesAt

Values must be of type <class ‘float’>

delete

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

lblOffset

Values must be of type <class ‘int’>

majorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

majorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

majorTimeUnit

Value must be one of {‘months’, ‘years’, ‘days’}

majorUnit

Values must be of type <class ‘float’>

minorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

minorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

minorTimeUnit

Value must be one of {‘months’, ‘years’, ‘days’}

minorUnit

Values must be of type <class ‘float’>

numFmt

Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>

scaling

Values must be of type <class ‘openpyxl.chart.axis.Scaling’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dateAx'
tickLblPos

Value must be one of {‘low’, ‘nextTo’, ‘high’}

title

Values must be of type <class ‘openpyxl.chart.title.Title’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.axis.DisplayUnitsLabel(layout=None, tx=None, spPr=None, txPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layout

Values must be of type <class ‘openpyxl.chart.layout.Layout’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dispUnitsLbl'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

textPropertes

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tx

Values must be of type <class ‘openpyxl.chart.text.Text’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.axis.DisplayUnitsLabelList(custUnit=None, builtInUnit=None, dispUnitsLbl=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

builtInUnit

Value must be one of {‘billions’, ‘hundredMillions’, ‘trillions’, ‘tenThousands’, ‘tenMillions’, ‘thousands’, ‘hundredThousands’, ‘hundreds’, ‘millions’}

custUnit

Values must be of type <class ‘float’>

dispUnitsLbl

Values must be of type <class ‘openpyxl.chart.axis.DisplayUnitsLabel’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

tagname = 'dispUnits'
class openpyxl.chart.axis.NumericAxis(crossBetween=None, majorUnit=None, minorUnit=None, dispUnits=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.axis._BaseAxis

axId

Values must be of type <class ‘int’>

axPos

Value must be one of {‘r’, ‘t’, ‘b’, ‘l’}

crossAx

Values must be of type <class ‘int’>

crossBetween

Value must be one of {‘between’, ‘midCat’}

crosses

Value must be one of {‘min’, ‘max’, ‘autoZero’}

crossesAt

Values must be of type <class ‘float’>

delete

Values must be of type <class ‘bool’>

dispUnits

Values must be of type <class ‘openpyxl.chart.axis.DisplayUnitsLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

classmethod from_tree(node)[source]

Special case value axes with no gridlines

majorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

majorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

majorUnit

Values must be of type <class ‘float’>

minorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

minorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

minorUnit

Values must be of type <class ‘float’>

numFmt

Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>

scaling

Values must be of type <class ‘openpyxl.chart.axis.Scaling’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'valAx'
tickLblPos

Value must be one of {‘low’, ‘nextTo’, ‘high’}

title

Values must be of type <class ‘openpyxl.chart.title.Title’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.axis.Scaling(logBase=None, orientation='minMax', max=None, min=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

logBase

Values must be of type <class ‘float’>

max

Values must be of type <class ‘float’>

min

Values must be of type <class ‘float’>

orientation

Value must be one of {‘maxMin’, ‘minMax’}

tagname = 'scaling'
class openpyxl.chart.axis.SeriesAxis(tickLblSkip=None, tickMarkSkip=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.axis._BaseAxis

axId

Values must be of type <class ‘int’>

axPos

Value must be one of {‘r’, ‘t’, ‘b’, ‘l’}

crossAx

Values must be of type <class ‘int’>

crosses

Value must be one of {‘min’, ‘max’, ‘autoZero’}

crossesAt

Values must be of type <class ‘float’>

delete

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

majorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

majorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

minorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

minorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

numFmt

Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>

scaling

Values must be of type <class ‘openpyxl.chart.axis.Scaling’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'serAx'
tickLblPos

Value must be one of {‘low’, ‘nextTo’, ‘high’}

tickLblSkip

Values must be of type <class ‘int’>

tickMarkSkip

Values must be of type <class ‘int’>

title

Values must be of type <class ‘openpyxl.chart.title.Title’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.axis.TextAxis(auto=None, lblAlgn=None, lblOffset=100, tickLblSkip=None, tickMarkSkip=None, noMultiLvlLbl=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.axis._BaseAxis

auto

Values must be of type <class ‘bool’>

axId

Values must be of type <class ‘int’>

axPos

Value must be one of {‘r’, ‘t’, ‘b’, ‘l’}

crossAx

Values must be of type <class ‘int’>

crosses

Value must be one of {‘min’, ‘max’, ‘autoZero’}

crossesAt

Values must be of type <class ‘float’>

delete

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

lblAlgn

Value must be one of {‘r’, ‘l’, ‘ctr’}

lblOffset

Values must be of type <class ‘float’>

majorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

majorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

minorGridlines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

minorTickMark

Value must be one of {‘out’, ‘cross’, ‘in’}

noMultiLvlLbl

Values must be of type <class ‘bool’>

numFmt

Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>

scaling

Values must be of type <class ‘openpyxl.chart.axis.Scaling’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'catAx'
tickLblPos

Value must be one of {‘low’, ‘nextTo’, ‘high’}

tickLblSkip

Values must be of type <class ‘int’>

tickMarkSkip

Values must be of type <class ‘int’>

title

Values must be of type <class ‘openpyxl.chart.title.Title’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

openpyxl.chart.bar_chart module
class openpyxl.chart.bar_chart.BarChart(gapWidth=150, overlap=None, serLines=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.bar_chart._BarChartBase

barDir

Value must be one of {‘col’, ‘bar’}

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gapWidth

Values must be of type <class ‘float’>

grouping

Value must be one of {‘clustered’, ‘stacked’, ‘standard’, ‘percentStacked’}

overlap

Values must be of type <class ‘float’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

serLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

tagname = 'barChart'
varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

class openpyxl.chart.bar_chart.BarChart3D(gapWidth=150, gapDepth=150, shape=None, serLines=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.bar_chart._BarChartBase, openpyxl.chart._3d._3DBase

backWall

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

barDir

Value must be one of {‘col’, ‘bar’}

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

floor

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

gapDepth

Values must be of type <class ‘float’>

gapWidth

Values must be of type <class ‘float’>

grouping

Value must be one of {‘clustered’, ‘stacked’, ‘standard’, ‘percentStacked’}

ser

A sequence (list or tuple) that may only contain objects of the declared type

serLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

shape

Value must be one of {‘cone’, ‘pyramid’, ‘cylinder’, ‘coneToMax’, ‘box’, ‘pyramidToMax’}

sideWall

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

tagname = 'bar3DChart'
varyColors

Values must be of type <class ‘bool’>

view3D

Values must be of type <class ‘openpyxl.chart._3d.View3D’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

z_axis

Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>

openpyxl.chart.bubble_chart module
class openpyxl.chart.bubble_chart.BubbleChart(varyColors=None, ser=(), dLbls=None, bubble3D=None, bubbleScale=None, showNegBubbles=None, sizeRepresents=None, extLst=None, **kw)[source]

Bases: openpyxl.chart._chart.ChartBase

bubble3D

Values must be of type <class ‘bool’>

bubbleScale

Values must be of type <class ‘float’>

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dataLabels

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

showNegBubbles

Values must be of type <class ‘bool’>

sizeRepresents

Value must be one of {‘w’, ‘area’}

tagname = 'bubbleChart'
varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

openpyxl.chart.chartspace module

Enclosing chart object. The various chart types are actually child objects. Will probably need to call this indirectly

class openpyxl.chart.chartspace.ChartContainer(title=None, autoTitleDeleted=None, pivotFmts=(), view3D=None, floor=None, sideWall=None, backWall=None, plotArea=None, legend=None, plotVisOnly=True, dispBlanksAs='gap', showDLblsOverMax=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoTitleDeleted

Values must be of type <class ‘bool’>

backWall

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

dispBlanksAs

Value must be one of {‘gap’, ‘zero’, ‘span’}

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

floor

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

legend

Values must be of type <class ‘openpyxl.chart.legend.Legend’>

pivotFmts

Wrap a sequence in an containing object

plotArea

Values must be of type <class ‘openpyxl.chart.plotarea.PlotArea’>

plotVisOnly

Values must be of type <class ‘bool’>

showDLblsOverMax

Values must be of type <class ‘bool’>

sideWall

Values must be of type <class ‘openpyxl.chart._3d.Surface’>

tagname = 'chart'
title

Values must be of type <class ‘openpyxl.chart.title.Title’>

view3D

Values must be of type <class ‘openpyxl.chart._3d.View3D’>

class openpyxl.chart.chartspace.ChartSpace(date1904=None, lang=None, roundedCorners=None, style=None, clrMapOvr=None, pivotSource=None, protection=None, chart=None, spPr=None, txPr=None, externalData=None, printSettings=None, userShapes=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chart

Values must be of type <class ‘openpyxl.chart.chartspace.ChartContainer’>

clrMapOvr

Values must be of type <class ‘openpyxl.drawing.colors.ColorMapping’>

date1904

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

externalData

Values must be of type <class ‘openpyxl.chart.chartspace.ExternalData’>

graphical_properties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

lang

Values must be of type <class ‘str’>

pivotSource

Values must be of type <class ‘openpyxl.chart.pivot.PivotSource’>

printSettings

Values must be of type <class ‘openpyxl.chart.print_settings.PrintSettings’>

protection

Values must be of type <class ‘openpyxl.chart.chartspace.Protection’>

roundedCorners

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

style

Values must be of type <class ‘float’>

tagname = 'chartSpace'
textProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

to_tree(tagname=None, idx=None, namespace=None)[source]
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

userShapes

Values must be of type <class ‘str’>

class openpyxl.chart.chartspace.ExternalData(autoUpdate=None, id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoUpdate

Values must be of type <class ‘bool’>

id

Values must be of type <class ‘str’>

tagname = 'externalData'
class openpyxl.chart.chartspace.Protection(chartObject=None, data=None, formatting=None, selection=None, userInterface=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chartObject

Values must be of type <class ‘bool’>

data

Values must be of type <class ‘bool’>

formatting

Values must be of type <class ‘bool’>

selection

Values must be of type <class ‘bool’>

tagname = 'protection'
userInterface

Values must be of type <class ‘bool’>

openpyxl.chart.data_source module

Collection of utility primitives for charts.

class openpyxl.chart.data_source.AxDataSource(numRef=None, numLit=None, strRef=None, strLit=None, multiLvlStrRef=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

multiLvlStrRef

Values must be of type <class ‘openpyxl.chart.data_source.MultiLevelStrRef’>

numLit

Values must be of type <class ‘openpyxl.chart.data_source.NumData’>

numRef

Values must be of type <class ‘openpyxl.chart.data_source.NumRef’>

strLit

Values must be of type <class ‘openpyxl.chart.data_source.StrData’>

strRef

Values must be of type <class ‘openpyxl.chart.data_source.StrRef’>

tagname = 'cat'
class openpyxl.chart.data_source.Level(pt=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

pt

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'lvl'
class openpyxl.chart.data_source.MultiLevelStrData(ptCount=None, lvl=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

lvl

A sequence (list or tuple) that may only contain objects of the declared type

ptCount

Values must be of type <class ‘int’>

tagname = 'multiLvlStrData'
class openpyxl.chart.data_source.MultiLevelStrRef(f=None, multiLvlStrCache=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

f

Values must be of type <class ‘str’>

multiLvlStrCache

Values must be of type <class ‘openpyxl.chart.data_source.MultiLevelStrData’>

tagname = 'multiLvlStrRef'
class openpyxl.chart.data_source.NumData(formatCode=None, ptCount=None, pt=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

formatCode

Values must be of type <class ‘str’>

pt

A sequence (list or tuple) that may only contain objects of the declared type

ptCount

Values must be of type <class ‘int’>

class openpyxl.chart.data_source.NumDataSource(numRef=None, numLit=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

numLit

Values must be of type <class ‘openpyxl.chart.data_source.NumData’>

numRef

Values must be of type <class ‘openpyxl.chart.data_source.NumRef’>

class openpyxl.chart.data_source.NumFmt(formatCode=None, sourceLinked=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

formatCode

Values must be of type <class ‘str’>

sourceLinked

Values must be of type <class ‘bool’>

class openpyxl.chart.data_source.NumRef(f=None, numCache=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

f

Values must be of type <class ‘str’>

numCache

Values must be of type <class ‘openpyxl.chart.data_source.NumData’>

ref

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.chart.data_source.NumVal(idx=None, formatCode=None, v=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

formatCode

Values must be of type <class ‘str’>

idx

Values must be of type <class ‘int’>

v

Values must be of type <class ‘NoneType’>

class openpyxl.chart.data_source.NumberValueDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedText

Data should be numerical but isn’t always :-/

allow_none = True
class openpyxl.chart.data_source.StrData(ptCount=None, pt=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

pt

A sequence (list or tuple) that may only contain objects of the declared type

ptCount

Values must be of type <class ‘int’>

tagname = 'strData'
class openpyxl.chart.data_source.StrRef(f=None, strCache=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

f

Values must be of type <class ‘str’>

strCache

Values must be of type <class ‘openpyxl.chart.data_source.StrData’>

tagname = 'strRef'
class openpyxl.chart.data_source.StrVal(idx=0, v=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

idx

Values must be of type <class ‘int’>

tagname = 'strVal'
v

Values must be of type <class ‘str’>

openpyxl.chart.descriptors module
class openpyxl.chart.descriptors.NestedGapAmount(**kw)[source]

Bases: openpyxl.descriptors.nested.NestedMinMax

allow_none = True
max = 500
min = 0
class openpyxl.chart.descriptors.NestedOverlap(**kw)[source]

Bases: openpyxl.descriptors.nested.NestedMinMax

allow_none = True
max = 100
min = -100
class openpyxl.chart.descriptors.NumberFormatDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

Allow direct assignment of format code

allow_none = True
expected_type

alias of openpyxl.chart.data_source.NumFmt

openpyxl.chart.error_bar module
class openpyxl.chart.error_bar.ErrorBars(errDir=None, errBarType='both', errValType='fixedVal', noEndCap=None, plus=None, minus=None, val=None, spPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

direction

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

errBarType

Value must be one of {‘minus’, ‘both’, ‘plus’}

errDir

Value must be one of {‘x’, ‘y’}

errValType

Value must be one of {‘cust’, ‘stdErr’, ‘fixedVal’, ‘stdDev’, ‘percentage’}

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

minus

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

noEndCap

Values must be of type <class ‘bool’>

plus

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

size

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

style

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'errBars'
val

Values must be of type <class ‘float’>

openpyxl.chart.label module
class openpyxl.chart.label.DataLabel(idx=0, **kw)[source]

Bases: openpyxl.chart.label._DataLabelBase

dLblPos

Value must be one of {‘inEnd’, ‘inBase’, ‘bestFit’, ‘ctr’, ‘outEnd’, ‘r’, ‘l’, ‘t’, ‘b’}

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

idx

Values must be of type <class ‘int’>

numFmt

Values must be of type <class ‘str’>

separator

Values must be of type <class ‘str’>

showBubbleSize

Values must be of type <class ‘bool’>

showCatName

Values must be of type <class ‘bool’>

showLeaderLines

Values must be of type <class ‘bool’>

showLegendKey

Values must be of type <class ‘bool’>

showPercent

Values must be of type <class ‘bool’>

showSerName

Values must be of type <class ‘bool’>

showVal

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dLbl'
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.label.DataLabelList(dLbl=(), delete=None, **kw)[source]

Bases: openpyxl.chart.label._DataLabelBase

dLbl

A sequence (list or tuple) that may only contain objects of the declared type

dLblPos

Value must be one of {‘inEnd’, ‘inBase’, ‘bestFit’, ‘ctr’, ‘outEnd’, ‘r’, ‘l’, ‘t’, ‘b’}

delete

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

numFmt

Values must be of type <class ‘str’>

separator

Values must be of type <class ‘str’>

showBubbleSize

Values must be of type <class ‘bool’>

showCatName

Values must be of type <class ‘bool’>

showLeaderLines

Values must be of type <class ‘bool’>

showLegendKey

Values must be of type <class ‘bool’>

showPercent

Values must be of type <class ‘bool’>

showSerName

Values must be of type <class ‘bool’>

showVal

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dLbls'
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

openpyxl.chart.layout module
class openpyxl.chart.layout.Layout(manualLayout=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

manualLayout

Values must be of type <class ‘openpyxl.chart.layout.ManualLayout’>

tagname = 'layout'
class openpyxl.chart.layout.ManualLayout(layoutTarget=None, xMode=None, yMode=None, wMode='factor', hMode='factor', x=None, y=None, w=None, h=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

h

Values must be of type <class ‘float’>

hMode

Value must be one of {‘edge’, ‘factor’}

height

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layoutTarget

Value must be one of {‘inner’, ‘outer’}

tagname = 'manualLayout'
w

Values must be of type <class ‘float’>

wMode

Value must be one of {‘edge’, ‘factor’}

width

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

x

Values must be of type <class ‘float’>

xMode

Value must be one of {‘edge’, ‘factor’}

y

Values must be of type <class ‘float’>

yMode

Value must be one of {‘edge’, ‘factor’}

openpyxl.chart.legend module
class openpyxl.chart.legend.Legend(legendPos='r', legendEntry=(), layout=None, overlay=None, spPr=None, txPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layout

Values must be of type <class ‘openpyxl.chart.layout.Layout’>

legendEntry

A sequence (list or tuple) that may only contain objects of the declared type

legendPos

Value must be one of {‘r’, ‘l’, ‘t’, ‘b’, ‘tr’}

overlay

Values must be of type <class ‘bool’>

position

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'legend'
textProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.legend.LegendEntry(idx=0, delete=False, txPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

delete

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

idx

Values must be of type <class ‘int’>

tagname = 'legendEntry'
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

openpyxl.chart.line_chart module
class openpyxl.chart.line_chart.LineChart(hiLowLines=None, upDownBars=None, marker=None, smooth=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.line_chart._LineChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dropLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

grouping

Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}

hiLowLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

marker

Values must be of type <class ‘bool’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

smooth

Values must be of type <class ‘bool’>

tagname = 'lineChart'
upDownBars

Values must be of type <class ‘openpyxl.chart.updown_bars.UpDownBars’>

varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis._BaseAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

class openpyxl.chart.line_chart.LineChart3D(gapDepth=None, hiLowLines=None, upDownBars=None, marker=None, smooth=None, **kw)[source]

Bases: openpyxl.chart.line_chart._LineChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dropLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gapDepth

Values must be of type <class ‘float’>

grouping

Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}

hiLowLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

marker

Values must be of type <class ‘bool’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

smooth

Values must be of type <class ‘bool’>

tagname = 'line3DChart'
upDownBars

Values must be of type <class ‘openpyxl.chart.updown_bars.UpDownBars’>

varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

z_axis

Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>

openpyxl.chart.marker module
class openpyxl.chart.marker.DataPoint(idx=None, invertIfNegative=None, marker=None, bubble3D=None, explosion=None, spPr=None, pictureOptions=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bubble3D

Values must be of type <class ‘bool’>

explosion

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

idx

Values must be of type <class ‘int’>

invertIfNegative

Values must be of type <class ‘bool’>

marker

Values must be of type <class ‘openpyxl.chart.marker.Marker’>

pictureOptions

Values must be of type <class ‘openpyxl.chart.picture.PictureOptions’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dPt'
class openpyxl.chart.marker.Marker(symbol=None, size=None, spPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

size

Values must be of type <class ‘float’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

symbol

Value must be one of {‘auto’, ‘dash’, ‘dot’, ‘plus’, ‘star’, ‘diamond’, ‘picture’, ‘x’, ‘square’, ‘triangle’, ‘circle’}

tagname = 'marker'
openpyxl.chart.picture module
class openpyxl.chart.picture.PictureOptions(applyToFront=None, applyToSides=None, applyToEnd=None, pictureFormat=None, pictureStackUnit=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

applyToEnd

Values must be of type <class ‘bool’>

applyToFront

Values must be of type <class ‘bool’>

applyToSides

Values must be of type <class ‘bool’>

pictureFormat

Value must be one of {‘stack’, ‘stackScale’, ‘stretch’}

pictureStackUnit

Values must be of type <class ‘float’>

tagname = 'pictureOptions'
openpyxl.chart.pie_chart module
class openpyxl.chart.pie_chart.CustomSplit(secondPiePt=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

secondPiePt

A sequence of primitive types that are stored as a single attribute. “val” is the default attribute

tagname = 'custSplit'
class openpyxl.chart.pie_chart.DoughnutChart(firstSliceAng=0, holeSize=10, extLst=None, **kw)[source]

Bases: openpyxl.chart.pie_chart._PieChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

firstSliceAng

Values must be of type <class ‘float’>

holeSize

Values must be of type <class ‘float’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'doughnutChart'
varyColors

Values must be of type <class ‘bool’>

class openpyxl.chart.pie_chart.PieChart(firstSliceAng=0, extLst=None, **kw)[source]

Bases: openpyxl.chart.pie_chart._PieChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

firstSliceAng

Values must be of type <class ‘float’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'pieChart'
varyColors

Values must be of type <class ‘bool’>

class openpyxl.chart.pie_chart.PieChart3D(varyColors=True, ser=(), dLbls=None)[source]

Bases: openpyxl.chart.pie_chart._PieChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'pie3DChart'
varyColors

Values must be of type <class ‘bool’>

class openpyxl.chart.pie_chart.ProjectedPieChart(ofPieType='pie', gapWidth=None, splitType='auto', splitPos=None, custSplit=None, secondPieSize=75, serLines=None, extLst=None, **kw)[source]

Bases: openpyxl.chart.pie_chart._PieChartBase

From the spec 21.2.2.126

This element contains the pie of pie or bar of pie series on this chart. Only the first series shall be displayed. The splitType element shall determine whether the splitPos and custSplit elements apply.

custSplit

Values must be of type <class ‘openpyxl.chart.pie_chart.CustomSplit’>

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gapWidth

Values must be of type <class ‘float’>

join_lines

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

ofPieType

Value must be one of {‘pie’, ‘bar’}

secondPieSize

Values must be of type <class ‘float’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

serLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

splitPos

Values must be of type <class ‘float’>

splitType

Value must be one of {‘cust’, ‘pos’, ‘auto’, ‘percent’, ‘val’}

tagname = 'ofPieChart'
type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

varyColors

Values must be of type <class ‘bool’>

openpyxl.chart.pivot module
class openpyxl.chart.pivot.PivotFormat(idx=0, spPr=None, txPr=None, marker=None, dLbl=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

DataLabel

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

TextBody

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

dLbl

Values must be of type <class ‘openpyxl.chart.label.DataLabel’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

idx

Values must be of type <class ‘int’>

marker

Values must be of type <class ‘openpyxl.chart.marker.Marker’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'pivotFmt'
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.pivot.PivotSource(name=None, fmtId=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fmtId

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

tagname = 'pivotSource'
openpyxl.chart.plotarea module
class openpyxl.chart.plotarea.DataTable(showHorzBorder=None, showVertBorder=None, showOutline=None, showKeys=None, spPr=None, txPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

showHorzBorder

Values must be of type <class ‘bool’>

showKeys

Values must be of type <class ‘bool’>

showOutline

Values must be of type <class ‘bool’>

showVertBorder

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'dTable'
txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.plotarea.PlotArea(layout=None, dTable=None, spPr=None, _charts=(), _axes=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

area3DChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

areaChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

bar3DChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

barChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

bubbleChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

catAx

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

dTable

Values must be of type <class ‘openpyxl.chart.plotarea.DataTable’>

dateAx

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

doughnutChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

classmethod from_tree(node)[source]

Create object from XML

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layout

Values must be of type <class ‘openpyxl.chart.layout.Layout’>

line3DChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

lineChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

ofPieChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

pie3DChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

pieChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

radarChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

scatterChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

serAx

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

stockChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

surface3DChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

surfaceChart

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

tagname = 'plotArea'
to_tree(tagname=None, idx=None, namespace=None)[source]
valAx

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

openpyxl.chart.print_settings module
class openpyxl.chart.print_settings.PageMargins(l=0.75, r=0.75, t=1, b=1, header=0.5, footer=0.5)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Identical to openpyxl.worksheet.page.Pagemargins but element names are different :-/

b

Values must be of type <class ‘float’>

bottom

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

footer

Values must be of type <class ‘float’>

header

Values must be of type <class ‘float’>

l

Values must be of type <class ‘float’>

left

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

r

Values must be of type <class ‘float’>

right

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

t

Values must be of type <class ‘float’>

tagname = 'pageMargins'
top

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.chart.print_settings.PrintSettings(headerFooter=None, pageMargins=None, pageSetup=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

headerFooter

Values must be of type <class ‘openpyxl.worksheet.header_footer.HeaderFooter’>

pageMargins

Values must be of type <class ‘openpyxl.chart.print_settings.PageMargins’>

pageSetup

Values must be of type <class ‘openpyxl.worksheet.page.PrintPageSetup’>

tagname = 'printSettings'
openpyxl.chart.radar_chart module
class openpyxl.chart.radar_chart.RadarChart(radarStyle='standard', varyColors=None, ser=(), dLbls=None, extLst=None, **kw)[source]

Bases: openpyxl.chart._chart.ChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dataLabels

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

radarStyle

Value must be one of {‘marker’, ‘standard’, ‘filled’}

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'radarChart'
type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

openpyxl.chart.reader module

Read a chart

openpyxl.chart.reader.read_chart(chartspace)[source]
openpyxl.chart.reference module
class openpyxl.chart.reference.DummyWorksheet(title)[source]

Bases: object

class openpyxl.chart.reference.Reference(worksheet=None, min_col=None, min_row=None, max_col=None, max_row=None, range_string=None)[source]

Bases: openpyxl.descriptors.Strict

Normalise cell range references

cols

Return all columns in the range

max_col

Values must be of type <class ‘int’>

max_row

Values must be of type <class ‘int’>

min_col

Values must be of type <class ‘int’>

min_row

Values must be of type <class ‘int’>

pop()[source]

Return and remove the first cell

range_string

Values must be of type <class ‘str’>

rows

Return all rows in the range

sheetname
openpyxl.chart.scatter_chart module
class openpyxl.chart.scatter_chart.ScatterChart(scatterStyle=None, varyColors=None, ser=(), dLbls=None, extLst=None, **kw)[source]

Bases: openpyxl.chart._chart.ChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dataLabels

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

scatterStyle

Value must be one of {‘lineMarker’, ‘smoothMarker’, ‘smooth’, ‘line’, ‘marker’}

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'scatterChart'
varyColors

Values must be of type <class ‘bool’>

x_axis

Values must be of type (<class ‘openpyxl.chart.axis.NumericAxis’>, <class ‘openpyxl.chart.axis.TextAxis’>)

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

openpyxl.chart.series module
class openpyxl.chart.series.Series(idx=0, order=0, tx=None, spPr=None, pictureOptions=None, dPt=(), dLbls=None, trendline=None, errBars=None, cat=None, val=None, invertIfNegative=None, shape=None, xVal=None, yVal=None, bubbleSize=None, bubble3D=None, marker=None, smooth=None, explosion=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Generic series object. Should not be instantiated directly. User the chart.Series factory instead.

bubble3D

Values must be of type <class ‘bool’>

bubbleSize

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

cat

Values must be of type <class ‘openpyxl.chart.data_source.AxDataSource’>

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dPt

A sequence (list or tuple) that may only contain objects of the declared type

data_points

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

errBars

Values must be of type <class ‘openpyxl.chart.error_bar.ErrorBars’>

explosion

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

identifiers

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

idx

Values must be of type <class ‘int’>

invertIfNegative

Values must be of type <class ‘bool’>

labels

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

marker

Values must be of type <class ‘openpyxl.chart.marker.Marker’>

order

Values must be of type <class ‘int’>

pictureOptions

Values must be of type <class ‘openpyxl.chart.picture.PictureOptions’>

shape

Value must be one of {‘cone’, ‘pyramid’, ‘cylinder’, ‘coneToMax’, ‘box’, ‘pyramidToMax’}

smooth

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'ser'
title

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

to_tree(tagname=None, idx=None)[source]

The index can need rebasing

trendline

Values must be of type <class ‘openpyxl.chart.trendline.Trendline’>

tx

Values must be of type <class ‘openpyxl.chart.series.SeriesLabel’>

val

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

xVal

Values must be of type <class ‘openpyxl.chart.data_source.AxDataSource’>

yVal

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

zVal

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.chart.series.SeriesLabel(strRef=None, v=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

strRef

Values must be of type <class ‘openpyxl.chart.data_source.StrRef’>

tagname = 'tx'
v

Values must be of type <class ‘str’>

value

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.chart.series.XYSeries(idx=0, order=0, tx=None, spPr=None, pictureOptions=None, dPt=(), dLbls=None, trendline=None, errBars=None, cat=None, val=None, invertIfNegative=None, shape=None, xVal=None, yVal=None, bubbleSize=None, bubble3D=None, marker=None, smooth=None, explosion=None, extLst=None)[source]

Bases: openpyxl.chart.series.Series

Dedicated series for charts that have x and y series

bubble3D

Values must be of type <class ‘bool’>

bubbleSize

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dPt

A sequence (list or tuple) that may only contain objects of the declared type

errBars

Values must be of type <class ‘openpyxl.chart.error_bar.ErrorBars’>

idx

Values must be of type <class ‘int’>

invertIfNegative

Values must be of type <class ‘bool’>

marker

Values must be of type <class ‘openpyxl.chart.marker.Marker’>

order

Values must be of type <class ‘int’>

smooth

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

trendline

Values must be of type <class ‘openpyxl.chart.trendline.Trendline’>

tx

Values must be of type <class ‘openpyxl.chart.series.SeriesLabel’>

xVal

Values must be of type <class ‘openpyxl.chart.data_source.AxDataSource’>

yVal

Values must be of type <class ‘openpyxl.chart.data_source.NumDataSource’>

openpyxl.chart.series_factory module
openpyxl.chart.series_factory.SeriesFactory(values, xvalues=None, zvalues=None, title=None, title_from_data=False)[source]

Convenience Factory for creating chart data series.

openpyxl.chart.shapes module
class openpyxl.chart.shapes.GraphicalProperties(bwMode=None, xfrm=None, noFill=None, solidFill=None, gradFill=None, pattFill=None, ln=None, scene3d=None, custGeom=None, prstGeom=None, sp3d=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Somewhat vaguely 21.2.2.197 says this:

This element specifies the formatting for the parent chart element. The custGeom, prstGeom, scene3d, and xfrm elements are not supported. The bwMode attribute is not supported.

This doesn’t leave much. And the element is used in different places.

bwMode

Value must be one of {‘hidden’, ‘clr’, ‘invGray’, ‘ltGray’, ‘blackGray’, ‘white’, ‘grayWhite’, ‘auto’, ‘blackWhite’, ‘black’, ‘gray’}

custGeom

Values must be of type <class ‘openpyxl.drawing.geometry.CustomGeometry2D’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gradFill

Values must be of type <class ‘openpyxl.drawing.fill.GradientFillProperties’>

line

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

ln

Values must be of type <class ‘openpyxl.drawing.line.LineProperties’>

noFill

Values must be of type <class ‘bool’>

pattFill

Values must be of type <class ‘openpyxl.drawing.fill.PatternFillProperties’>

prstGeom

Values must be of type <class ‘openpyxl.drawing.geometry.PresetGeometry2D’>

scene3d

Values must be of type <class ‘openpyxl.drawing.geometry.Scene3D’>

shape3D

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

solidFill

Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>

sp3d

Values must be of type <class ‘openpyxl.drawing.geometry.Shape3D’>

tagname = 'spPr'
transform

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

xfrm

Values must be of type <class ‘openpyxl.drawing.geometry.Transform2D’>

openpyxl.chart.stock_chart module
class openpyxl.chart.stock_chart.StockChart(ser=(), dLbls=None, dropLines=None, hiLowLines=None, upDownBars=None, extLst=None, **kw)[source]

Bases: openpyxl.chart._chart.ChartBase

dLbls

Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>

dataLabels

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

dropLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

hiLowLines

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'stockChart'
upDownBars

Values must be of type <class ‘openpyxl.chart.updown_bars.UpDownBars’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

openpyxl.chart.surface_chart module
class openpyxl.chart.surface_chart.BandFormat(idx=0, spPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

idx

Values must be of type <class ‘int’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'bandFmt'
class openpyxl.chart.surface_chart.BandFormatList(bandFmt=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bandFmt

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'bandFmts'
class openpyxl.chart.surface_chart.SurfaceChart(**kw)[source]

Bases: openpyxl.chart.surface_chart.SurfaceChart3D

bandFmts

Values must be of type <class ‘openpyxl.chart.surface_chart.BandFormatList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'surfaceChart'
wireframe

Values must be of type <class ‘bool’>

class openpyxl.chart.surface_chart.SurfaceChart3D(**kw)[source]

Bases: openpyxl.chart.surface_chart._SurfaceChartBase, openpyxl.chart._3d._3DBase

bandFmts

Values must be of type <class ‘openpyxl.chart.surface_chart.BandFormatList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ser

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'surface3DChart'
wireframe

Values must be of type <class ‘bool’>

x_axis

Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>

y_axis

Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>

z_axis

Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>

openpyxl.chart.text module
class openpyxl.chart.text.RichText(bodyPr=None, lstStyle=None, p=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

From the specification: 21.2.2.216

This element specifies text formatting. The lstStyle element is not supported.

bodyPr

Values must be of type <class ‘openpyxl.drawing.text.RichTextProperties’>

lstStyle

Values must be of type <class ‘openpyxl.drawing.text.ListStyle’>

p

A sequence (list or tuple) that may only contain objects of the declared type

paragraphs

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

properties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'rich'
class openpyxl.chart.text.Text(strRef=None, rich=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

The value can be either a cell reference or a text element If both are present then the reference will be used.

rich

Values must be of type <class ‘openpyxl.chart.text.RichText’>

strRef

Values must be of type <class ‘openpyxl.chart.data_source.StrRef’>

tagname = 'tx'
to_tree(tagname=None, idx=None, namespace=None)[source]
openpyxl.chart.title module
class openpyxl.chart.title.Title(tx=None, layout=None, overlay=None, spPr=None, txPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

body

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layout

Values must be of type <class ‘openpyxl.chart.layout.Layout’>

overlay

Values must be of type <class ‘bool’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'title'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tx

Values must be of type <class ‘openpyxl.chart.text.Text’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.chart.title.TitleDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

allow_none = True
expected_type

alias of Title

openpyxl.chart.title.title_maker(text)[source]
openpyxl.chart.trendline module
class openpyxl.chart.trendline.Trendline(name=None, spPr=None, trendlineType='linear', order=None, period=None, forward=None, backward=None, intercept=None, dispRSqr=None, dispEq=None, trendlineLbl=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

backward

Values must be of type <class ‘float’>

dispEq

Values must be of type <class ‘bool’>

dispRSqr

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

forward

Values must be of type <class ‘float’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

intercept

Values must be of type <class ‘float’>

name

Values must be of type <class ‘str’>

order

Values must be of type <class ‘int’>

period

Values must be of type <class ‘int’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'trendline'
trendlineLbl

Values must be of type <class ‘openpyxl.chart.trendline.TrendlineLabel’>

trendlineType

Value must be one of {‘log’, ‘power’, ‘linear’, ‘exp’, ‘poly’, ‘movingAvg’}

class openpyxl.chart.trendline.TrendlineLabel(layout=None, tx=None, numFmt=None, spPr=None, txPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

layout

Values must be of type <class ‘openpyxl.chart.layout.Layout’>

numFmt

Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

tagname = 'trendlineLbl'
textProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tx

Values must be of type <class ‘openpyxl.chart.text.Text’>

txPr

Values must be of type <class ‘openpyxl.chart.text.RichText’>

openpyxl.chart.updown_bars module
class openpyxl.chart.updown_bars.UpDownBars(gapWidth=150, upBars=None, downBars=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

downBars

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gapWidth

Values must be of type <class ‘float’>

tagname = 'upbars'
upBars

Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>

openpyxl.chartsheet package
Submodules
openpyxl.chartsheet.chartsheet module
class openpyxl.chartsheet.chartsheet.Chartsheet(sheetPr=None, sheetViews=None, sheetProtection=None, customSheetViews=None, pageMargins=None, pageSetup=None, headerFooter=None, drawing=None, drawingHF=None, picture=None, webPublishItems=None, extLst=None, parent=None, title='', sheet_state='visible')[source]

Bases: openpyxl.workbook.child._WorkbookChild, openpyxl.descriptors.serialisable.Serialisable

HeaderFooter

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

add_chart(chart)[source]
customSheetViews

Values must be of type <class ‘openpyxl.chartsheet.custom.CustomChartsheetViews’>

drawing

Values must be of type <class ‘openpyxl.worksheet.drawing.Drawing’>

drawingHF

Values must be of type <class ‘openpyxl.chartsheet.relation.DrawingHF’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

headerFooter

Values must be of type <class ‘openpyxl.worksheet.header_footer.HeaderFooter’>

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml'
pageMargins

Values must be of type <class ‘openpyxl.worksheet.page.PageMargins’>

pageSetup

Values must be of type <class ‘openpyxl.worksheet.page.PrintPageSetup’>

picture

Values must be of type <class ‘openpyxl.chartsheet.relation.SheetBackgroundPicture’>

sheetPr

Values must be of type <class ‘openpyxl.chartsheet.properties.ChartsheetProperties’>

sheetProtection

Values must be of type <class ‘openpyxl.chartsheet.protection.ChartsheetProtection’>

sheetViews

Values must be of type <class ‘openpyxl.chartsheet.views.ChartsheetViewList’>

sheet_state

Value must be one of {‘visible’, ‘hidden’, ‘veryHidden’}

tagname = 'chartsheet'
to_tree()[source]
webPublishItems

Values must be of type <class ‘openpyxl.chartsheet.publish.WebPublishItems’>

openpyxl.chartsheet.custom module
class openpyxl.chartsheet.custom.CustomChartsheetView(guid=None, scale=None, state='visible', zoomToFit=None, pageMargins=None, pageSetup=None, headerFooter=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

guid
headerFooter

Values must be of type <class ‘openpyxl.worksheet.header_footer.HeaderFooter’>

pageMargins

Values must be of type <class ‘openpyxl.worksheet.page.PageMargins’>

pageSetup

Values must be of type <class ‘openpyxl.worksheet.page.PrintPageSetup’>

scale

Values must be of type <class ‘int’>

state

Value must be one of {‘visible’, ‘hidden’, ‘veryHidden’}

tagname = 'customSheetView'
zoomToFit

Values must be of type <class ‘bool’>

class openpyxl.chartsheet.custom.CustomChartsheetViews(customSheetView=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customSheetView

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'customSheetViews'
openpyxl.chartsheet.properties module
class openpyxl.chartsheet.properties.ChartsheetProperties(published=None, codeName=None, tabColor=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

codeName

Values must be of type <class ‘str’>

published

Values must be of type <class ‘bool’>

tabColor

Values must be of type <class ‘openpyxl.styles.colors.Color’>

tagname = 'sheetPr'
openpyxl.chartsheet.protection module
class openpyxl.chartsheet.protection.ChartsheetProtection(content=None, objects=None, hashValue=None, spinCount=None, saltValue=None, algorithmName=None, password=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable, openpyxl.worksheet.protection._Protected

algorithmName

Values must be of type <class ‘str’>

content

Values must be of type <class ‘bool’>

hashValue
objects

Values must be of type <class ‘bool’>

saltValue
spinCount

Values must be of type <class ‘int’>

tagname = 'sheetProtection'
openpyxl.chartsheet.publish module
class openpyxl.chartsheet.publish.WebPublishItem(id=None, divId=None, sourceType=None, sourceRef=None, sourceObject=None, destinationFile=None, title=None, autoRepublish=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoRepublish

Values must be of type <class ‘bool’>

destinationFile

Values must be of type <class ‘str’>

divId

Values must be of type <class ‘str’>

id

Values must be of type <class ‘int’>

sourceObject

Values must be of type <class ‘str’>

sourceRef

Values must be of type <class ‘str’>

sourceType

Value must be one of {‘label’, ‘pivotTable’, ‘query’, ‘printArea’, ‘autoFilter’, ‘sheet’, ‘range’, ‘chart’}

tagname = 'webPublishItem'
title

Values must be of type <class ‘str’>

class openpyxl.chartsheet.publish.WebPublishItems(count=None, webPublishItem=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

tagname = 'WebPublishItems'
webPublishItem

A sequence (list or tuple) that may only contain objects of the declared type

openpyxl.chartsheet.relation module
class openpyxl.chartsheet.relation.DrawingHF(id=None, lho=None, lhe=None, lhf=None, cho=None, che=None, chf=None, rho=None, rhe=None, rhf=None, lfo=None, lfe=None, lff=None, cfo=None, cfe=None, cff=None, rfo=None, rfe=None, rff=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

centerFooterEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

centerFooterFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

centerFooterOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

centerHeaderEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

centerHeaderFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

centerHeaderOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

cfe

Values must be of type <class ‘int’>

cff

Values must be of type <class ‘int’>

cfo

Values must be of type <class ‘int’>

che

Values must be of type <class ‘int’>

chf

Values must be of type <class ‘int’>

cho

Values must be of type <class ‘int’>

id

Values must be of type <class ‘str’>

leftFooterEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

leftFooterFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

leftFooterOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

leftHeaderEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

leftHeaderFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

leftHeaderOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

lfe

Values must be of type <class ‘int’>

lff

Values must be of type <class ‘int’>

lfo

Values must be of type <class ‘int’>

lhe

Values must be of type <class ‘int’>

lhf

Values must be of type <class ‘int’>

lho

Values must be of type <class ‘int’>

rfe

Values must be of type <class ‘int’>

rff

Values must be of type <class ‘int’>

rfo

Values must be of type <class ‘int’>

rhe

Values must be of type <class ‘int’>

rhf

Values must be of type <class ‘int’>

rho

Values must be of type <class ‘int’>

rightFooterEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rightFooterFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rightFooterOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rightHeaderEvenPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rightHeaderFirstPage

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rightHeaderOddPages

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.chartsheet.relation.SheetBackgroundPicture(id)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

tagname = 'picture'
openpyxl.chartsheet.views module
class openpyxl.chartsheet.views.ChartsheetView(tabSelected=None, zoomScale=None, workbookViewId=0, zoomToFit=True, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

tabSelected

Values must be of type <class ‘bool’>

tagname = 'sheetView'
workbookViewId

Values must be of type <class ‘int’>

zoomScale

Values must be of type <class ‘int’>

zoomToFit

Values must be of type <class ‘bool’>

class openpyxl.chartsheet.views.ChartsheetViewList(sheetView=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

sheetView

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'sheetViews'
openpyxl.comments package
Submodules
openpyxl.comments.author module
class openpyxl.comments.author.AuthorList(author=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

author

A sequence (list or tuple) that may only contain objects of the declared type

authors

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'authors'
openpyxl.comments.comment_sheet module
class openpyxl.comments.comment_sheet.CommentRecord(ref='', authorId=0, guid=None, shapeId=0, text=None, commentPr=None, author=None, height=79, width=144)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

author

Values must be of type <class ‘str’>

authorId

Values must be of type <class ‘int’>

commentPr

Values must be of type <class ‘openpyxl.comments.comment_sheet.Properties’>

content

Remove all inline formatting and stuff

classmethod from_cell(cell)[source]

Class method to convert cell comment

guid
ref

Values must be of type <class ‘str’>

shapeId

Values must be of type <class ‘int’>

tagname = 'comment'
text

Values must be of type <class ‘openpyxl.cell.text.Text’>

class openpyxl.comments.comment_sheet.CommentSheet(authors=None, commentList=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

authors

Values must be of type <class ‘openpyxl.comments.author.AuthorList’>

commentList

Wrap a sequence in an containing object

comments

Return a dictionary of comments keyed by coord

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

classmethod from_comments(comments)[source]

Create a comment sheet from a list of comments for a particular worksheet

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml'
path

Return path within the archive

tagname = 'comments'
to_tree()[source]
write_shapes(vml=None)[source]

Create the VML for comments

class openpyxl.comments.comment_sheet.Properties(locked=None, defaultSize=None, _print=None, disabled=None, uiObject=None, autoFill=None, autoLine=None, altText=None, textHAlign=None, textVAlign=None, lockText=None, justLastX=None, autoScale=None, rowHidden=None, colHidden=None, anchor=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

altText

Values must be of type <class ‘str’>

autoFill

Values must be of type <class ‘bool’>

autoLine

Values must be of type <class ‘bool’>

autoScale

Values must be of type <class ‘bool’>

colHidden

Values must be of type <class ‘bool’>

defaultSize

Values must be of type <class ‘bool’>

disabled

Values must be of type <class ‘bool’>

justLastX

Values must be of type <class ‘bool’>

lockText

Values must be of type <class ‘bool’>

locked

Values must be of type <class ‘bool’>

rowHidden

Values must be of type <class ‘bool’>

textHAlign

Value must be one of {‘right’, ‘justify’, ‘left’, ‘center’, ‘distributed’}

textVAlign

Value must be one of {‘distributed’, ‘justify’, ‘center’, ‘bottom’, ‘top’}

uiObject

Values must be of type <class ‘bool’>

openpyxl.comments.comments module
class openpyxl.comments.comments.Comment(text, author, height=79, width=144)[source]

Bases: object

bind(cell)[source]

Bind comment to a particular cell

parent
text

Any comment text stripped of all formatting.

unbind()[source]

Unbind a comment from a cell

openpyxl.comments.shape_writer module
class openpyxl.comments.shape_writer.ShapeWriter(comments)[source]

Bases: object

Create VML for comments

add_comment_shape(root, idx, coord, height, width)[source]
add_comment_shapetype(root)[source]
vml = None
vml_path = None
write(root)[source]
openpyxl.descriptors package
class openpyxl.descriptors.MetaSerialisable[source]

Bases: type

class openpyxl.descriptors.MetaStrict[source]

Bases: type

class openpyxl.descriptors.Strict[source]

Bases: object

Submodules
openpyxl.descriptors.base module

Based on Python Cookbook 3rd Edition, 8.13 http://chimera.labs.oreilly.com/books/1230000000393/ch08.html#_discussiuncion_130

class openpyxl.descriptors.base.ASCII(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

expected_type

alias of builtins.bytes

class openpyxl.descriptors.base.Alias(alias)[source]

Bases: openpyxl.descriptors.base.Descriptor

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.descriptors.base.Bool(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Convertible

expected_type

alias of builtins.bool

class openpyxl.descriptors.base.Convertible(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

Values must be convertible to a particular type

class openpyxl.descriptors.base.DateTime(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

expected_type

alias of datetime.datetime

class openpyxl.descriptors.base.Default(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

When called returns an instance of the expected type. Additional default values can be passed in to the descriptor

class openpyxl.descriptors.base.Descriptor(name=None, **kw)[source]

Bases: object

class openpyxl.descriptors.base.Float(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Convertible

expected_type

alias of builtins.float

class openpyxl.descriptors.base.Integer(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Convertible

expected_type

alias of builtins.int

class openpyxl.descriptors.base.Length(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

class openpyxl.descriptors.base.MatchPattern(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

Values must match a regex pattern

allow_none = False
class openpyxl.descriptors.base.Max(**kw)[source]

Bases: openpyxl.descriptors.base.Convertible

Values must be less than a max value

allow_none = False
expected_type

alias of builtins.float

class openpyxl.descriptors.base.Min(**kw)[source]

Bases: openpyxl.descriptors.base.Convertible

Values must be greater than a min value

allow_none = False
expected_type

alias of builtins.float

class openpyxl.descriptors.base.MinMax(**kw)[source]

Bases: openpyxl.descriptors.base.Min, openpyxl.descriptors.base.Max

Values must be greater than min value and less than a max one

class openpyxl.descriptors.base.NoneSet(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Set

‘none’ will be treated as None

class openpyxl.descriptors.base.Set(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

Value can only be from a set of know values

class openpyxl.descriptors.base.String(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

expected_type

alias of builtins.str

class openpyxl.descriptors.base.Text(*args, **kw)[source]

Bases: openpyxl.descriptors.base.String, openpyxl.descriptors.base.Convertible

class openpyxl.descriptors.base.Tuple(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

expected_type

alias of builtins.tuple

class openpyxl.descriptors.base.Typed(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

Values must of a particular type

allow_none = False
expected_type

alias of builtins.NoneType

nested = False
openpyxl.descriptors.excel module

Excel specific descriptors

class openpyxl.descriptors.excel.Base64Binary(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.MatchPattern

pattern = '^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$'
class openpyxl.descriptors.excel.CellRange(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.MatchPattern

allow_none = True
pattern = '^[$]?([A-Za-z]{1,3})[$]?(\\d+)(:[$]?([A-Za-z]{1,3})[$]?(\\d+)?)?$|^[A-Za-z]{1,3}:[A-Za-z]{1,3}$'
class openpyxl.descriptors.excel.Extension(uri=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

uri

Values must be of type <class ‘str’>

class openpyxl.descriptors.excel.ExtensionList(ext=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ext

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.descriptors.excel.Guid(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.MatchPattern

pattern = '{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}\\}'
class openpyxl.descriptors.excel.HexBinary(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.MatchPattern

pattern = '[0-9a-fA-F]+$'
class openpyxl.descriptors.excel.Percentage(**kw)[source]

Bases: openpyxl.descriptors.base.MinMax

max = 1000000
min = -1000000
pattern = '((100)|([0-9][0-9]?))(\\.[0-9][0-9]?)?%'
class openpyxl.descriptors.excel.Relation(*args, **kw)[source]

Bases: openpyxl.descriptors.base.String

allow_none = True
namespace = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'
class openpyxl.descriptors.excel.TextPoint(**kw)[source]

Bases: openpyxl.descriptors.base.MinMax

Size in hundredths of points. In theory other units of measurement can be used but these are unbounded

expected_type

alias of builtins.int

max = 400000
min = -400000
class openpyxl.descriptors.excel.UniversalMeasure(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.MatchPattern

pattern = '[0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi)'
openpyxl.descriptors.namespace module
openpyxl.descriptors.namespace.namespaced(obj, tagname, namespace=None)[source]

Utility to create a namespaced tag for an object

openpyxl.descriptors.nested module

Generic serialisable classes

class openpyxl.descriptors.nested.EmptyTag(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.Bool

Boolean if a tag exists or not.

from_tree(node)[source]
to_tree(tagname=None, value=None, namespace=None)[source]
class openpyxl.descriptors.nested.Nested(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

attribute = 'val'
from_tree(node)[source]
nested = True
to_tree(tagname=None, value=None, namespace=None)[source]
class openpyxl.descriptors.nested.NestedBool(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Bool

from_tree(node)[source]
class openpyxl.descriptors.nested.NestedFloat(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Float

class openpyxl.descriptors.nested.NestedInteger(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Integer

class openpyxl.descriptors.nested.NestedMinMax(**kw)[source]

Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.MinMax

class openpyxl.descriptors.nested.NestedNoneSet(name=None, **kw)[source]

Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.NoneSet

class openpyxl.descriptors.nested.NestedSet(name=None, **kw)[source]

Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.Set

class openpyxl.descriptors.nested.NestedString(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.String

class openpyxl.descriptors.nested.NestedText(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.NestedValue

Represents any nested tag with the value as the contents of the tag

from_tree(node)[source]
to_tree(tagname=None, value=None, namespace=None)[source]
class openpyxl.descriptors.nested.NestedValue(*args, **kw)[source]

Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.Convertible

Nested tag storing the value on the ‘val’ attribute

openpyxl.descriptors.sequence module
class openpyxl.descriptors.sequence.MultiSequence(name=None, **kw)[source]

Bases: openpyxl.descriptors.sequence.Sequence

Sequences can contain objects with different tags

to_tree(tagname, obj, namespace=None)[source]

Convert the sequence represented by the descriptor to an XML element

class openpyxl.descriptors.sequence.MultiSequencePart(expected_type, store)[source]

Bases: openpyxl.descriptors.base.Alias

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

class openpyxl.descriptors.sequence.NestedSequence(name=None, **kw)[source]

Bases: openpyxl.descriptors.sequence.Sequence

Wrap a sequence in an containing object

count = False
from_tree(node)[source]
to_tree(tagname, obj, namespace=None)[source]

Convert the sequence represented by the descriptor to an XML element

class openpyxl.descriptors.sequence.Sequence(name=None, **kw)[source]

Bases: openpyxl.descriptors.base.Descriptor

A sequence (list or tuple) that may only contain objects of the declared type

container

alias of builtins.list

expected_type

alias of builtins.NoneType

idx_base = 0
seq_types = (<class 'list'>, <class 'tuple'>)
to_tree(tagname, obj, namespace=None)[source]

Convert the sequence represented by the descriptor to an XML element

unique = False
class openpyxl.descriptors.sequence.UniqueSequence(name=None, **kw)[source]

Bases: openpyxl.descriptors.sequence.Sequence

Use a set to keep values unique

container

alias of builtins.set

seq_types = (<class 'list'>, <class 'tuple'>, <class 'set'>)
class openpyxl.descriptors.sequence.ValueSequence(name=None, **kw)[source]

Bases: openpyxl.descriptors.sequence.Sequence

A sequence of primitive types that are stored as a single attribute. “val” is the default attribute

attribute = 'val'
from_tree(node)[source]
to_tree(tagname, obj, namespace=None)[source]

Convert the sequence represented by the descriptor to an XML element

openpyxl.descriptors.serialisable module
class openpyxl.descriptors.serialisable.Serialisable[source]

Bases: object

Objects can serialise to XML their attributes and child objects. The following class attributes are created by the metaclass at runtime: __attrs__ = attributes __nested__ = single-valued child treated as an attribute __elements__ = child elements

classmethod from_tree(node)[source]

Create object from XML

idx_base = 0
namespace = None
tagname
to_tree(tagname=None, idx=None, namespace=None)[source]
openpyxl.drawing package
Submodules
openpyxl.drawing.colors module
class openpyxl.drawing.colors.ColorChoice(scrgbClr=None, srgbClr=None, hslClr=None, sysClr=None, schemeClr=None, prstClr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

RGB

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

RGBPercent

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

tagname = 'colorChoice'
class openpyxl.drawing.colors.ColorChoiceDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

Objects can choose from 7 different kinds of color system. Assume RGBHex if a string is passed in.

allow_none = True
expected_type

alias of ColorChoice

class openpyxl.drawing.colors.ColorMapping(bg1='lt1', tx1='dk1', bg2='lt2', tx2='dk2', accent1='accent1', accent2='accent2', accent3='accent3', accent4='accent4', accent5='accent5', accent6='accent6', hlink='hlink', folHlink='folHlink', extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

accent1

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

accent2

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

accent3

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

accent4

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

accent5

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

accent6

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

bg1

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

bg2

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

tagname = 'clrMapOvr'
tx1

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

tx2

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘hlink’}

class openpyxl.drawing.colors.HSLColor(hue=None, sat=None, lum=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

hue

Values must be of type <class ‘int’>

lum

Values must be of type <class ‘float’>

sat

Values must be of type <class ‘float’>

tagname = 'hslClr'
class openpyxl.drawing.colors.RGBPercent(r=None, g=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘float’>

g

Values must be of type <class ‘float’>

r

Values must be of type <class ‘float’>

tagname = 'rgbClr'
class openpyxl.drawing.colors.SchemeColor(tint=None, shade=None, comp=None, inv=None, gray=None, alpha=None, alphaOff=None, alphaMod=None, hue=None, hueOff=None, hueMod=None, sat=None, satOff=None, satMod=None, lum=None, lumOff=None, lumMod=None, red=None, redOff=None, redMod=None, green=None, greenOff=None, greenMod=None, blue=None, blueOff=None, blueMod=None, gamma=None, invGamma=None, val=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alpha

Values must be of type <class ‘int’>

alphaMod

Values must be of type <class ‘int’>

alphaOff

Values must be of type <class ‘int’>

blue

Values must be of type <class ‘int’>

blueMod

Values must be of type <class ‘int’>

blueOff

Values must be of type <class ‘int’>

comp

Values must be of type <class ‘bool’>

gamma

Values must be of type <class ‘bool’>

gray

Values must be of type <class ‘int’>

green

Values must be of type <class ‘int’>

greenMod

Values must be of type <class ‘int’>

greenOff

Values must be of type <class ‘int’>

hue

Values must be of type <class ‘int’>

hueMod

Values must be of type <class ‘int’>

hueOff

Values must be of type <class ‘int’>

inv

Values must be of type <class ‘int’>

invGamma

Values must be of type <class ‘bool’>

lum

Values must be of type <class ‘int’>

lumMod

Values must be of type <class ‘int’>

lumOff

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
red

Values must be of type <class ‘int’>

redMod

Values must be of type <class ‘int’>

redOff

Values must be of type <class ‘int’>

sat

Values must be of type <class ‘int’>

satMod

Values must be of type <class ‘int’>

satOff

Values must be of type <class ‘int’>

shade

Values must be of type <class ‘int’>

tagname = 'schemeClr'
tint

Values must be of type <class ‘int’>

val

Value must be one of {‘accent5’, ‘dk2’, ‘lt2’, ‘dk1’, ‘accent3’, ‘folHlink’, ‘accent2’, ‘accent4’, ‘tx1’, ‘accent1’, ‘accent6’, ‘hlink’, ‘bg1’, ‘lt1’, ‘phClr’, ‘bg2’, ‘tx2’}

class openpyxl.drawing.colors.SystemColor(val='windowText', lastClr=None, tint=None, shade=None, comp=None, inv=None, gray=None, alpha=None, alphaOff=None, alphaMod=None, hue=None, hueOff=None, hueMod=None, sat=None, satOff=None, satMod=None, lum=None, lumOff=None, lumMod=None, red=None, redOff=None, redMod=None, green=None, greenOff=None, greenMod=None, blue=None, blueOff=None, blueMod=None, gamma=None, invGamma=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alpha

Values must be of type <class ‘int’>

alphaMod

Values must be of type <class ‘int’>

alphaOff

Values must be of type <class ‘int’>

blue

Values must be of type <class ‘int’>

blueMod

Values must be of type <class ‘int’>

blueOff

Values must be of type <class ‘int’>

comp

Values must be of type <class ‘openpyxl.drawing.colors.Transform’>

gamma

Values must be of type <class ‘openpyxl.drawing.colors.Transform’>

gray

Values must be of type <class ‘openpyxl.drawing.colors.Transform’>

green

Values must be of type <class ‘int’>

greenMod

Values must be of type <class ‘int’>

greenOff

Values must be of type <class ‘int’>

hue

Values must be of type <class ‘int’>

hueMod

Values must be of type <class ‘int’>

hueOff

Values must be of type <class ‘int’>

inv

Values must be of type <class ‘openpyxl.drawing.colors.Transform’>

invGamma

Values must be of type <class ‘openpyxl.drawing.colors.Transform’>

lastClr

Values must be of type <class ‘str’>

lum

Values must be of type <class ‘int’>

lumMod

Values must be of type <class ‘int’>

lumOff

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
red

Values must be of type <class ‘int’>

redMod

Values must be of type <class ‘int’>

redOff

Values must be of type <class ‘int’>

sat

Values must be of type <class ‘int’>

satMod

Values must be of type <class ‘int’>

satOff

Values must be of type <class ‘int’>

shade

Values must be of type <class ‘int’>

tagname = 'sysClr'
tint

Values must be of type <class ‘int’>

val

Value must be one of {‘btnText’, ‘scrollBar’, ‘captionText’, ‘menuText’, ‘infoText’, ‘windowFrame’, ‘inactiveBorder’, ‘btnFace’, ‘activeBorder’, ‘btnHighlight’, ‘hotLight’, ‘highlight’, ‘grayText’, ‘gradientActiveCaption’, ‘window’, ‘menu’, ‘inactiveCaptionText’, ‘activeCaption’, ‘3dLight’, ‘appWorkspace’, ‘windowText’, ‘inactiveCaption’, ‘background’, ‘menuHighlight’, ‘menuBar’, ‘3dDkShadow’, ‘infoBk’, ‘highlightText’, ‘gradientInactiveCaption’, ‘btnShadow’}

class openpyxl.drawing.colors.Transform[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

openpyxl.drawing.connector module
class openpyxl.drawing.connector.Connection(id=None, idx=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘int’>

idx

Values must be of type <class ‘int’>

class openpyxl.drawing.connector.ConnectorLocking(extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

class openpyxl.drawing.connector.ConnectorNonVisual(cNvPr=None, cNvCxnSpPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cNvCxnSpPr

Values must be of type <class ‘openpyxl.drawing.connector.NonVisualConnectorProperties’>

cNvPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingProps’>

class openpyxl.drawing.connector.ConnectorShape(nvCxnSpPr=None, spPr=None, style=None, macro=None, fPublished=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fPublished

Values must be of type <class ‘bool’>

macro

Values must be of type <class ‘str’>

nvCxnSpPr

Values must be of type <class ‘openpyxl.drawing.connector.ConnectorNonVisual’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

style

Values must be of type <class ‘openpyxl.drawing.geometry.ShapeStyle’>

tagname = 'cxnSp'
class openpyxl.drawing.connector.NonVisualConnectorProperties(cxnSpLocks=None, stCxn=None, endCxn=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cxnSpLocks

Values must be of type <class ‘openpyxl.drawing.connector.ConnectorLocking’>

endCxn

Values must be of type <class ‘openpyxl.drawing.connector.Connection’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

stCxn

Values must be of type <class ‘openpyxl.drawing.connector.Connection’>

class openpyxl.drawing.connector.Shape(macro=None, textlink=None, fPublished=None, fLocksText=None, nvSpPr=None, spPr=None, style=None, txBody=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fLocksText

Values must be of type <class ‘bool’>

fPublished

Values must be of type <class ‘bool’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

macro

Values must be of type <class ‘str’>

meta

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

nvSpPr

Values must be of type <class ‘openpyxl.drawing.connector.ShapeMeta’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

style

Values must be of type <class ‘openpyxl.drawing.geometry.ShapeStyle’>

Values must be of type <class ‘str’>

txBody

Values must be of type <class ‘openpyxl.chart.text.RichText’>

class openpyxl.drawing.connector.ShapeMeta(cNvPr=None, cNvSpPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cNvPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingProps’>

cNvSpPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingShapeProps’>

tagname = 'nvSpPr'
openpyxl.drawing.drawing module
class openpyxl.drawing.drawing.Drawing[source]

Bases: object

a drawing object - eg container for shapes or charts we assume user specifies dimensions in pixels; units are converted to EMU in the drawing part

anchor
count = 0
height
set_dimension(w=0, h=0)[source]
width
openpyxl.drawing.effect module
class openpyxl.drawing.effect.AlphaBiLevelEffect(thresh=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

thresh

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.AlphaCeilingEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.AlphaFloorEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.AlphaInverseEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.AlphaModulateEffect(cont=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cont

Values must be of type <class ‘openpyxl.drawing.effect.EffectContainer’>

class openpyxl.drawing.effect.AlphaModulateFixedEffect(amt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

amt

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.AlphaReplaceEffect(a=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

a

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.BiLevelEffect(thresh=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

thresh

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.BlurEffect(rad=None, grow=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

grow

Values must be of type <class ‘bool’>

rad

Values must be of type <class ‘float’>

class openpyxl.drawing.effect.Color[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.ColorChangeEffect(useA=None, clrFrom=None, clrTo=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

clrFrom

Values must be of type <class ‘openpyxl.drawing.effect.Color’>

clrTo

Values must be of type <class ‘openpyxl.drawing.effect.Color’>

useA

Values must be of type <class ‘bool’>

class openpyxl.drawing.effect.ColorReplaceEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.DuotoneEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.effect.EffectContainer(type=None, name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

type

Value must be one of {‘sib’, ‘tree’}

class openpyxl.drawing.effect.EffectList(blur=None, fillOverlay=None, glow=None, innerShdw=None, outerShdw=None, prstShdw=None, reflection=None, softEdge=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blur

Values must be of type <class ‘openpyxl.drawing.effect.BlurEffect’>

fillOverlay

Values must be of type <class ‘openpyxl.drawing.effect.FillOverlayEffect’>

glow

Values must be of type <class ‘openpyxl.drawing.effect.GlowEffect’>

innerShdw

Values must be of type <class ‘openpyxl.drawing.effect.InnerShadowEffect’>

outerShdw

Values must be of type <class ‘openpyxl.drawing.effect.OuterShadow’>

prstShdw

Values must be of type <class ‘openpyxl.drawing.effect.PresetShadowEffect’>

reflection

Values must be of type <class ‘openpyxl.drawing.effect.ReflectionEffect’>

softEdge

Values must be of type <class ‘openpyxl.drawing.effect.SoftEdgesEffect’>

class openpyxl.drawing.effect.FillOverlayEffect(blend=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blend

Value must be one of {‘mult’, ‘darken’, ‘over’, ‘lighten’, ‘screen’}

class openpyxl.drawing.effect.GlowEffect(rad=None, **kw)[source]

Bases: openpyxl.drawing.colors.ColorChoice

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

rad

Values must be of type <class ‘float’>

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

class openpyxl.drawing.effect.GrayscaleEffect[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'grayscl'
class openpyxl.drawing.effect.HSLEffect(hue=None, sat=None, lum=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

hue

Values must be of type <class ‘int’>

lum

Values must be of type <class ‘int’>

sat

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.InnerShadowEffect(blurRad=None, dist=None, dir=None, **kw)[source]

Bases: openpyxl.drawing.colors.ColorChoice

blurRad

Values must be of type <class ‘float’>

dir

Values must be of type <class ‘int’>

dist

Values must be of type <class ‘float’>

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

class openpyxl.drawing.effect.LuminanceEffect(bright=0, contrast=0)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bright

Values must be of type <class ‘int’>

contrast

Values must be of type <class ‘int’>

tagname = 'lum'
class openpyxl.drawing.effect.OuterShadow(blurRad=None, dist=None, dir=None, sx=None, sy=None, kx=None, ky=None, algn=None, rotWithShape=None, **kw)[source]

Bases: openpyxl.drawing.colors.ColorChoice

algn

Value must be one of {‘tl’, ‘ctr’, ‘r’, ‘bl’, ‘l’, ‘br’, ‘t’, ‘b’, ‘tr’}

blurRad

Values must be of type <class ‘float’>

dir

Values must be of type <class ‘int’>

dist

Values must be of type <class ‘float’>

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

kx

Values must be of type <class ‘int’>

ky

Values must be of type <class ‘int’>

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

rotWithShape

Values must be of type <class ‘bool’>

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sx

Values must be of type <class ‘int’>

sy

Values must be of type <class ‘int’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

tagname = 'outerShdw'
class openpyxl.drawing.effect.PresetShadowEffect(prst=None, dist=None, dir=None, **kw)[source]

Bases: openpyxl.drawing.colors.ColorChoice

dir

Values must be of type <class ‘int’>

dist

Values must be of type <class ‘float’>

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

prst

Value must be one of {‘shdw2’, ‘shdw12’, ‘shdw18’, ‘shdw19’, ‘shdw9’, ‘shdw10’, ‘shdw16’, ‘shdw15’, ‘shdw1’, ‘shdw7’, ‘shdw8’, ‘shdw14’, ‘shdw6’, ‘shdw17’, ‘shdw3’, ‘shdw20’, ‘shdw4’, ‘shdw13’, ‘shdw11’, ‘shdw5’}

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

class openpyxl.drawing.effect.ReflectionEffect(blurRad=None, stA=None, stPos=None, endA=None, endPos=None, dist=None, dir=None, fadeDir=None, sx=None, sy=None, kx=None, ky=None, algn=None, rotWithShape=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algn

Value must be one of {‘tl’, ‘ctr’, ‘r’, ‘bl’, ‘l’, ‘br’, ‘t’, ‘b’, ‘tr’}

blurRad

Values must be of type <class ‘float’>

dir

Values must be of type <class ‘int’>

dist

Values must be of type <class ‘float’>

endA

Values must be of type <class ‘int’>

endPos

Values must be of type <class ‘int’>

fadeDir

Values must be of type <class ‘int’>

kx

Values must be of type <class ‘int’>

ky

Values must be of type <class ‘int’>

rotWithShape

Values must be of type <class ‘bool’>

stA

Values must be of type <class ‘int’>

stPos

Values must be of type <class ‘int’>

sx

Values must be of type <class ‘int’>

sy

Values must be of type <class ‘int’>

class openpyxl.drawing.effect.SoftEdgesEffect(rad=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

rad

Values must be of type <class ‘float’>

class openpyxl.drawing.effect.TintEffect(hue=0, amt=0)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

amt

Values must be of type <class ‘int’>

hue

Values must be of type <class ‘int’>

tagname = 'tint'
openpyxl.drawing.fill module
class openpyxl.drawing.fill.Blip(cstate=None, embed=None, link=None, noGrp=None, noSelect=None, noRot=None, noChangeAspect=None, noMove=None, noResize=None, noEditPoints=None, noAdjustHandles=None, noChangeArrowheads=None, noChangeShapeType=None, extLst=None, alphaBiLevel=None, alphaCeiling=None, alphaFloor=None, alphaInv=None, alphaMod=None, alphaModFix=None, alphaRepl=None, biLevel=None, blur=None, clrChange=None, clrRepl=None, duotone=None, fillOverlay=None, grayscl=None, hsl=None, lum=None, tint=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alphaBiLevel

Values must be of type <class ‘openpyxl.drawing.effect.AlphaBiLevelEffect’>

alphaCeiling

Values must be of type <class ‘openpyxl.drawing.effect.AlphaCeilingEffect’>

alphaFloor

Values must be of type <class ‘openpyxl.drawing.effect.AlphaFloorEffect’>

alphaInv

Values must be of type <class ‘openpyxl.drawing.effect.AlphaInverseEffect’>

alphaMod

Values must be of type <class ‘openpyxl.drawing.effect.AlphaModulateEffect’>

alphaModFix

Values must be of type <class ‘openpyxl.drawing.effect.AlphaModulateFixedEffect’>

alphaRepl

Values must be of type <class ‘openpyxl.drawing.effect.AlphaReplaceEffect’>

biLevel

Values must be of type <class ‘openpyxl.drawing.effect.BiLevelEffect’>

blur

Values must be of type <class ‘openpyxl.drawing.effect.BlurEffect’>

clrChange

Values must be of type <class ‘openpyxl.drawing.effect.ColorChangeEffect’>

clrRepl

Values must be of type <class ‘openpyxl.drawing.effect.ColorReplaceEffect’>

cstate

Value must be one of {‘hqprint’, ‘screen’, ‘email’, ‘print’}

duotone

Values must be of type <class ‘openpyxl.drawing.effect.DuotoneEffect’>

embed

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fillOverlay

Values must be of type <class ‘openpyxl.drawing.effect.FillOverlayEffect’>

grayscl

Values must be of type <class ‘openpyxl.drawing.effect.GrayscaleEffect’>

hsl

Values must be of type <class ‘openpyxl.drawing.effect.HSLEffect’>

Values must be of type <class ‘str’>

lum

Values must be of type <class ‘openpyxl.drawing.effect.LuminanceEffect’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noAdjustHandles

Values must be of type <class ‘bool’>

noChangeArrowheads

Values must be of type <class ‘bool’>

noChangeAspect

Values must be of type <class ‘bool’>

noChangeShapeType

Values must be of type <class ‘bool’>

noEditPoints

Values must be of type <class ‘bool’>

noGrp

Values must be of type <class ‘bool’>

noMove

Values must be of type <class ‘bool’>

noResize

Values must be of type <class ‘bool’>

noRot

Values must be of type <class ‘bool’>

noSelect

Values must be of type <class ‘bool’>

tagname = 'blip'
tint

Values must be of type <class ‘openpyxl.drawing.effect.TintEffect’>

class openpyxl.drawing.fill.BlipFillProperties(dpi=None, rotWithShape=None, blip=None, tile=None, stretch=<openpyxl.drawing.fill.StretchInfoProperties object> Parameters: fillRect=<openpyxl.drawing.fill.RelativeRect object> Parameters: l=None, t=None, r=None, b=None, srcRect=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blip

Values must be of type <class ‘openpyxl.drawing.fill.Blip’>

dpi

Values must be of type <class ‘int’>

rotWithShape

Values must be of type <class ‘bool’>

srcRect

Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>

stretch

Values must be of type <class ‘openpyxl.drawing.fill.StretchInfoProperties’>

tagname = 'blipFill'
tile

Values must be of type <class ‘openpyxl.drawing.fill.TileInfoProperties’>

class openpyxl.drawing.fill.GradientFillProperties(flip=None, rotWithShape=None, gsLst=(), lin=None, path=None, tileRect=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

flip

Value must be one of {‘xy’, ‘x’, ‘y’}

gsLst

Wrap a sequence in an containing object

lin

Values must be of type <class ‘openpyxl.drawing.fill.LinearShadeProperties’>

linear

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
path

Values must be of type <class ‘openpyxl.drawing.fill.PathShadeProperties’>

rotWithShape

Values must be of type <class ‘bool’>

stop_list

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'gradFill'
tileRect

Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>

class openpyxl.drawing.fill.GradientStop(pos=None, scrgbClr=None, srgbClr=None, hslClr=None, sysClr=None, schemeClr=None, prstClr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

RGB

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

RGBPercent

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
pos

Values must be of type <class ‘float’>

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

tagname = 'gs'
class openpyxl.drawing.fill.LinearShadeProperties(ang=None, scaled=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ang

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
scaled

Values must be of type <class ‘bool’>

tagname = 'lin'
class openpyxl.drawing.fill.PathShadeProperties(path=None, fillToRect=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fillToRect

Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
path

Value must be one of {‘rect’, ‘shape’, ‘circle’}

tagname = 'path'
class openpyxl.drawing.fill.PatternFillProperties(prst=None, fgClr=None, bgClr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

background

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

bgClr

Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>

fgClr

Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>

foreground

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
preset

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

prst

Value must be one of {‘ltUpDiag’, ‘pct20’, ‘dashUpDiag’, ‘ltVert’, ‘diagCross’, ‘lgConfetti’, ‘horzBrick’, ‘pct40’, ‘dnDiag’, ‘dkDnDiag’, ‘solidDmnd’, ‘wave’, ‘trellis’, ‘ltDnDiag’, ‘pct50’, ‘upDiag’, ‘sphere’, ‘weave’, ‘narHorz’, ‘dkUpDiag’, ‘pct90’, ‘pct70’, ‘pct5’, ‘dkVert’, ‘openDmnd’, ‘dkHorz’, ‘dashHorz’, ‘dotDmnd’, ‘lgCheck’, ‘shingle’, ‘smGrid’, ‘wdDnDiag’, ‘dashDnDiag’, ‘plaid’, ‘pct30’, ‘horz’, ‘pct25’, ‘divot’, ‘lgGrid’, ‘vert’, ‘zigZag’, ‘pct80’, ‘pct60’, ‘dotGrid’, ‘diagBrick’, ‘smConfetti’, ‘ltHorz’, ‘dashVert’, ‘smCheck’, ‘cross’, ‘pct75’, ‘pct10’, ‘narVert’, ‘wdUpDiag’}

tagname = 'pattFill'
class openpyxl.drawing.fill.RelativeRect(l=None, t=None, r=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘float’>

bottom

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

l

Values must be of type <class ‘float’>

left

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
r

Values must be of type <class ‘float’>

right

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

t

Values must be of type <class ‘float’>

tagname = 'rect'
top

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.drawing.fill.SolidColorFillProperties(scrgbClr=None, srgbClr=None, hslClr=None, sysClr=None, schemeClr=None, prstClr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

RGB

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

RGBPercent

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

prstClr

Value must be one of {‘lightCyan’, ‘mediumOrchid’, ‘mediumAquamarine’, ‘mediumSeaGreen’, ‘maroon’, ‘mediumBlue’, ‘aliceBlue’, ‘lightYellow’, ‘mediumSlateBlue’, ‘lightGreen’, ‘khaki’, ‘cadetBlue’, ‘darkSeaGreen’, ‘darkSlateGray’, ‘gray’, ‘orange’, ‘mediumTurquoise’, ‘paleGreen’, ‘mediumPurple’, ‘darkSlateGrey’, ‘chartreuse’, ‘darkGray’, ‘tan’, ‘brown’, ‘lightGoldenrodYellow’, ‘slateGrey’, ‘coral’, ‘lightSalmon’, ‘medAquamarine’, ‘steelBlue’, ‘blanchedAlmond’, ‘cornflowerBlue’, ‘dkBlue’, ‘lightSlateGray’, ‘dkOliveGreen’, ‘greenYellow’, ‘blue’, ‘yellow’, ‘red’, ‘fuchsia’, ‘dkGoldenrod’, ‘dimGray’, ‘lightBlue’, ‘sandyBrown’, ‘chocolate’, ‘deepPink’, ‘hotPink’, ‘ltCoral’, ‘lemonChiffon’, ‘orangeRed’, ‘ivory’, ‘darkKhaki’, ‘olive’, ‘orchid’, ‘dkRed’, ‘ltSlateGray’, ‘dkSlateBlue’, ‘white’, ‘skyBlue’, ‘dimGrey’, ‘peachPuff’, ‘royalBlue’, ‘blueViolet’, ‘darkMagenta’, ‘antiqueWhite’, ‘darkRed’, ‘ltYellow’, ‘mintCream’, ‘lightCoral’, ‘crimson’, ‘darkOrchid’, ‘dkSlateGray’, ‘oldLace’, ‘lawnGreen’, ‘mediumSpringGreen’, ‘moccasin’, ‘azure’, ‘darkViolet’, ‘lightGray’, ‘darkTurquoise’, ‘dkKhaki’, ‘floralWhite’, ‘rosyBrown’, ‘lightSeaGreen’, ‘dkTurquoise’, ‘ltSteelBlue’, ‘teal’, ‘lavenderBlush’, ‘mistyRose’, ‘dkGray’, ‘ltGrey’, ‘dkSlateGrey’, ‘lightSkyBlue’, ‘oliveDrab’, ‘slateBlue’, ‘pink’, ‘lavender’, ‘cyan’, ‘darkGrey’, ‘dkMagenta’, ‘violet’, ‘dkSalmon’, ‘lightSteelBlue’, ‘ltSeaGreen’, ‘ghostWhite’, ‘darkGreen’, ‘peru’, ‘burlyWood’, ‘seaShell’, ‘dkOrange’, ‘dkOrchid’, ‘goldenrod’, ‘paleGoldenrod’, ‘dkSeaGreen’, ‘grey’, ‘paleTurquoise’, ‘dkCyan’, ‘saddleBrown’, ‘navy’, ‘purple’, ‘turquoise’, ‘wheat’, ‘dkViolet’, ‘black’, ‘aqua’, ‘darkGoldenrod’, ‘darkOliveGreen’, ‘green’, ‘medPurple’, ‘lightPink’, ‘ltPink’, ‘paleVioletRed’, ‘gainsboro’, ‘medBlue’, ‘darkSalmon’, ‘dodgerBlue’, ‘lime’, ‘navajoWhite’, ‘indigo’, ‘darkSlateBlue’, ‘plum’, ‘springGreen’, ‘slateGray’, ‘cornsilk’, ‘firebrick’, ‘indianRed’, ‘powderBlue’, ‘magenta’, ‘ltSlateGrey’, ‘medSeaGreen’, ‘snow’, ‘deepSkyBlue’, ‘lightSlateGrey’, ‘sienna’, ‘medSpringGreen’, ‘beige’, ‘dkGrey’, ‘ltGreen’, ‘dkGreen’, ‘ltBlue’, ‘medTurquoise’, ‘lightGrey’, ‘darkBlue’, ‘forestGreen’, ‘ltSalmon’, ‘yellowGreen’, ‘thistle’, ‘midnightBlue’, ‘medOrchid’, ‘limeGreen’, ‘bisque’, ‘darkOrange’, ‘tomato’, ‘honeydew’, ‘darkCyan’, ‘medVioletRed’, ‘salmon’, ‘ltGray’, ‘medSlateBlue’, ‘ltCyan’, ‘ltGoldenrodYellow’, ‘ltSkyBlue’, ‘linen’, ‘aquamarine’, ‘mediumVioletRed’, ‘seaGreen’, ‘silver’, ‘papayaWhip’, ‘whiteSmoke’, ‘gold’}

schemeClr

Values must be of type <class ‘openpyxl.drawing.colors.SchemeColor’>

scrgbClr

Values must be of type <class ‘openpyxl.drawing.colors.RGBPercent’>

srgbClr

Values must be of type <class ‘str’>

sysClr

Values must be of type <class ‘openpyxl.drawing.colors.SystemColor’>

tagname = 'solidFill'
class openpyxl.drawing.fill.StretchInfoProperties(fillRect=<openpyxl.drawing.fill.RelativeRect object> Parameters: l=None, t=None, r=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fillRect

Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'stretch'
class openpyxl.drawing.fill.TileInfoProperties(tx=None, ty=None, sx=None, sy=None, flip=None, algn=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algn

Value must be one of {‘tl’, ‘ctr’, ‘r’, ‘bl’, ‘l’, ‘br’, ‘t’, ‘b’, ‘tr’}

flip

Value must be one of {‘xy’, ‘x’, ‘y’}

sx

Values must be of type <class ‘int’>

sy

Values must be of type <class ‘int’>

tx

Values must be of type <class ‘int’>

ty

Values must be of type <class ‘int’>

openpyxl.drawing.geometry module
class openpyxl.drawing.geometry.AdjPoint2D(x=None, y=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

x

Values must be of type <class ‘int’>

y

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.AdjustHandleList[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.drawing.geometry.Backdrop(anchor=None, norm=None, up=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

anchor

Values must be of type <class ‘openpyxl.drawing.geometry.Point3D’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

norm

Values must be of type <class ‘openpyxl.drawing.geometry.Vector3D’>

up

Values must be of type <class ‘openpyxl.drawing.geometry.Vector3D’>

class openpyxl.drawing.geometry.Bevel(w=None, h=None, prst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

h

Values must be of type <class ‘int’>

prst

Value must be one of {‘slope’, ‘riblet’, ‘angle’, ‘relaxedInset’, ‘cross’, ‘convex’, ‘divot’, ‘artDeco’, ‘coolSlant’, ‘softRound’, ‘hardEdge’, ‘circle’}

tagname = 'bevel'
w

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.Camera(prst=None, fov=None, zoom=None, rot=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fov

Values must be of type <class ‘int’>

prst

Value must be one of {‘perspectiveRelaxedModerately’, ‘isometricOffAxis2Right’, ‘legacyPerspectiveBottom’, ‘perspectiveHeroicLeftFacing’, ‘legacyObliqueBottomRight’, ‘obliqueBottom’, ‘legacyPerspectiveTopLeft’, ‘isometricLeftDown’, ‘isometricOffAxis3Bottom’, ‘perspectiveLeft’, ‘obliqueTopRight’, ‘perspectiveHeroicRightFacing’, ‘isometricBottomUp’, ‘perspectiveBelow’, ‘perspectiveContrastingRightFacing’, ‘legacyPerspectiveFront’, ‘orthographicFront’, ‘obliqueTopLeft’, ‘isometricOffAxis2Top’, ‘obliqueBottomRight’, ‘obliqueTop’, ‘perspectiveAboveRightFacing’, ‘isometricOffAxis3Left’, ‘isometricRightUp’, ‘isometricRightDown’, ‘perspectiveContrastingLeftFacing’, ‘isometricOffAxis1Top’, ‘isometricOffAxis1Left’, ‘isometricOffAxis4Right’, ‘isometricOffAxis4Bottom’, ‘legacyPerspectiveLeft’, ‘obliqueBottomLeft’, ‘perspectiveHeroicExtremeRightFacing’, ‘isometricLeftUp’, ‘legacyObliqueTopLeft’, ‘legacyPerspectiveTopRight’, ‘isometricTopUp’, ‘legacyPerspectiveBottomRight’, ‘isometricBottomDown’, ‘isometricOffAxis4Left’, ‘legacyObliqueBottom’, ‘isometricOffAxis1Right’, ‘legacyObliqueFront’, ‘legacyObliqueBottomLeft’, ‘legacyObliqueTopRight’, ‘legacyPerspectiveRight’, ‘legacyPerspectiveBottomLeft’, ‘legacyObliqueTop’, ‘perspectiveHeroicExtremeLeftFacing’, ‘obliqueRight’, ‘isometricOffAxis3Right’, ‘perspectiveAboveLeftFacing’, ‘perspectiveAbove’, ‘perspectiveFront’, ‘isometricOffAxis2Left’, ‘obliqueLeft’, ‘legacyObliqueLeft’, ‘isometricTopDown’, ‘legacyPerspectiveTop’, ‘perspectiveRight’, ‘perspectiveRelaxed’, ‘legacyObliqueRight’}

rot

Values must be of type <class ‘openpyxl.drawing.geometry.SphereCoords’>

tagname = 'camera'
zoom

Values must be of type <class ‘openpyxl.descriptors.excel.Percentage’>

class openpyxl.drawing.geometry.ConnectionSite(ang=None, pos=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ang

Values must be of type <class ‘float’>

pos

Values must be of type <class ‘openpyxl.drawing.geometry.AdjPoint2D’>

class openpyxl.drawing.geometry.ConnectionSiteList(cxn=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cxn

Values must be of type <class ‘openpyxl.drawing.geometry.ConnectionSite’>

class openpyxl.drawing.geometry.CustomGeometry2D(avLst=None, gdLst=None, ahLst=None, cxnLst=None, rect=None, pathLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ahLst

Values must be of type <class ‘openpyxl.drawing.geometry.AdjustHandleList’>

avLst

Values must be of type <class ‘openpyxl.drawing.geometry.GeomGuideList’>

cxnLst

Values must be of type <class ‘openpyxl.drawing.geometry.ConnectionSiteList’>

gdLst

Values must be of type <class ‘openpyxl.drawing.geometry.GeomGuideList’>

pathLst

Values must be of type <class ‘openpyxl.drawing.geometry.Path2DList’>

class openpyxl.drawing.geometry.FontReference(idx=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

idx

Value must be one of {‘major’, ‘minor’}

class openpyxl.drawing.geometry.GeomGuide(name=None, fmla=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fmla

Values must be of type <class ‘str’>

name

Values must be of type <class ‘str’>

class openpyxl.drawing.geometry.GeomGuideList(gd=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

gd

Values must be of type <class ‘openpyxl.drawing.geometry.GeomGuide’>

class openpyxl.drawing.geometry.GeomRect(l=None, t=None, r=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘int’>

l

Values must be of type <class ‘int’>

r

Values must be of type <class ‘int’>

t

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.GroupTransform2D(rot=0, flipH=None, flipV=None, off=None, ext=None, chOff=None, chExt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chExt

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

chOff

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

ext

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

flipH

Values must be of type <class ‘bool’>

flipV

Values must be of type <class ‘bool’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
off

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

rot

Values must be of type <class ‘int’>

tagname = 'xfrm'
class openpyxl.drawing.geometry.LightRig(rig=None, dir=None, rot=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dir

Value must be one of {‘tl’, ‘r’, ‘bl’, ‘l’, ‘br’, ‘t’, ‘b’, ‘tr’}

rig

Value must be one of {‘legacyNormal4’, ‘harsh’, ‘flat’, ‘sunrise’, ‘legacyHarsh2’, ‘chilly’, ‘legacyHarsh3’, ‘legacyNormal1’, ‘threePt’, ‘brightRoom’, ‘balanced’, ‘legacyHarsh4’, ‘legacyFlat2’, ‘freezing’, ‘legacyFlat1’, ‘legacyFlat4’, ‘legacyNormal2’, ‘flood’, ‘legacyNormal3’, ‘sunset’, ‘soft’, ‘legacyHarsh1’, ‘contrasting’, ‘legacyFlat3’, ‘twoPt’, ‘glow’, ‘morning’}

rot

Values must be of type <class ‘openpyxl.drawing.geometry.SphereCoords’>

tagname = 'lightRig'
class openpyxl.drawing.geometry.Path2D(w=None, h=None, fill=None, stroke=None, extrusionOk=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extrusionOk

Values must be of type <class ‘bool’>

fill

Value must be one of {‘lightenLess’, ‘norm’, ‘darken’, ‘lighten’, ‘darkenLess’}

h

Values must be of type <class ‘float’>

stroke

Values must be of type <class ‘bool’>

w

Values must be of type <class ‘float’>

class openpyxl.drawing.geometry.Path2DList(path=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

path

Values must be of type <class ‘openpyxl.drawing.geometry.Path2D’>

class openpyxl.drawing.geometry.Point2D(x=None, y=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'off'
x

Values must be of type <class ‘int’>

y

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.Point3D(x=None, y=None, z=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'anchor'
x

Values must be of type <class ‘int’>

y

Values must be of type <class ‘int’>

z

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.PositiveSize2D(cx=None, cy=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cx

Values must be of type <class ‘int’>

cy

Values must be of type <class ‘int’>

height

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'

Dimensions in EMUs

tagname = 'ext'
width

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.drawing.geometry.PresetGeometry2D(prst=None, avLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

avLst

Values must be of type <class ‘openpyxl.drawing.geometry.GeomGuideList’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
prst

Value must be one of {‘pentagon’, ‘rightBracket’, ‘star32’, ‘flowChartOr’, ‘downArrow’, ‘quadArrowCallout’, ‘curvedConnector5’, ‘flowChartMerge’, ‘parallelogram’, ‘squareTabs’, ‘round2SameRect’, ‘star24’, ‘doubleWave’, ‘bentConnector3’, ‘dodecagon’, ‘curvedLeftArrow’, ‘plaque’, ‘stripedRightArrow’, ‘flowChartMagneticTape’, ‘mathMinus’, ‘snip1Rect’, ‘ribbon’, ‘curvedConnector3’, ‘ellipse’, ‘flowChartInputOutput’, ‘foldedCorner’, ‘plus’, ‘wedgeRectCallout’, ‘actionButtonBlank’, ‘uturnArrow’, ‘snip2SameRect’, ‘accentCallout3’, ‘irregularSeal2’, ‘borderCallout2’, ‘flowChartSummingJunction’, ‘flowChartOfflineStorage’, ‘leftBracket’, ‘star8’, ‘accentCallout2’, ‘donut’, ‘leftRightUpArrow’, ‘mathPlus’, ‘smileyFace’, ‘borderCallout3’, ‘actionButtonDocument’, ‘rect’, ‘upDownArrow’, ‘leftArrowCallout’, ‘bentConnector5’, ‘upDownArrowCallout’, ‘mathDivide’, ‘bentUpArrow’, ‘bentConnector2’, ‘round2DiagRect’, ‘mathMultiply’, ‘hexagon’, ‘flowChartProcess’, ‘curvedRightArrow’, ‘decagon’, ‘callout2’, ‘chevron’, ‘gear9’, ‘flowChartDecision’, ‘leftBrace’, ‘rightBrace’, ‘cloudCallout’, ‘notchedRightArrow’, ‘star16’, ‘leftCircularArrow’, ‘wedgeRoundRectCallout’, ‘octagon’, ‘chartStar’, ‘flowChartDelay’, ‘rightArrow’, ‘frame’, ‘line’, ‘mathNotEqual’, ‘irregularSeal1’, ‘gear6’, ‘noSmoking’, ‘moon’, ‘bentConnector4’, ‘flowChartManualOperation’, ‘plaqueTabs’, ‘lineInv’, ‘upArrow’, ‘horizontalScroll’, ‘star10’, ‘leftUpArrow’, ‘diagStripe’, ‘curvedDownArrow’, ‘corner’, ‘actionButtonBeginning’, ‘chord’, ‘leftRightRibbon’, ‘blockArc’, ‘leftArrow’, ‘bracketPair’, ‘flowChartMultidocument’, ‘actionButtonBackPrevious’, ‘chartPlus’, ‘flowChartConnector’, ‘star5’, ‘wedgeEllipseCallout’, ‘actionButtonEnd’, ‘star4’, ‘chartX’, ‘curvedConnector4’, ‘sun’, ‘triangle’, ‘rtTriangle’, ‘roundRect’, ‘lightningBolt’, ‘flowChartMagneticDisk’, ‘flowChartPunchedCard’, ‘round1Rect’, ‘flowChartPredefinedProcess’, ‘flowChartCollate’, ‘flowChartDisplay’, ‘curvedConnector2’, ‘flowChartDocument’, ‘cornerTabs’, ‘bracePair’, ‘actionButtonMovie’, ‘actionButtonSound’, ‘homePlate’, ‘star12’, ‘flowChartTerminator’, ‘actionButtonHome’, ‘accentBorderCallout3’, ‘cloud’, ‘actionButtonReturn’, ‘flowChartExtract’, ‘arc’, ‘swooshArrow’, ‘borderCallout1’, ‘mathEqual’, ‘accentBorderCallout1’, ‘heart’, ‘upArrowCallout’, ‘accentCallout1’, ‘star6’, ‘nonIsoscelesTrapezoid’, ‘pieWedge’, ‘leftRightCircularArrow’, ‘rightArrowCallout’, ‘leftRightArrowCallout’, ‘wave’, ‘quadArrow’, ‘halfFrame’, ‘straightConnector1’, ‘callout3’, ‘bentArrow’, ‘verticalScroll’, ‘snipRoundRect’, ‘ellipseRibbon2’, ‘flowChartSort’, ‘cube’, ‘pie’, ‘flowChartPreparation’, ‘flowChartAlternateProcess’, ‘bevel’, ‘downArrowCallout’, ‘flowChartOnlineStorage’, ‘heptagon’, ‘curvedUpArrow’, ‘accentBorderCallout2’, ‘callout1’, ‘funnel’, ‘actionButtonHelp’, ‘diamond’, ‘actionButtonInformation’, ‘flowChartManualInput’, ‘actionButtonForwardNext’, ‘circularArrow’, ‘flowChartMagneticDrum’, ‘ellipseRibbon’, ‘snip2DiagRect’, ‘can’, ‘trapezoid’, ‘flowChartPunchedTape’, ‘star7’, ‘ribbon2’, ‘flowChartOffpageConnector’, ‘flowChartInternalStorage’, ‘leftRightArrow’, ‘teardrop’}

class openpyxl.drawing.geometry.Scene3D(camera=None, lightRig=None, backdrop=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

backdrop

Values must be of type <class ‘openpyxl.drawing.geometry.Backdrop’>

camera

Values must be of type <class ‘openpyxl.drawing.geometry.Camera’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

lightRig

Values must be of type <class ‘openpyxl.drawing.geometry.LightRig’>

class openpyxl.drawing.geometry.Shape3D(z=None, extrusionH=None, contourW=None, prstMaterial=None, bevelT=None, bevelB=None, extrusionClr=None, contourClr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bevelB

Values must be of type <class ‘openpyxl.drawing.geometry.Bevel’>

bevelT

Values must be of type <class ‘openpyxl.drawing.geometry.Bevel’>

contourClr

Values must be of type <class ‘openpyxl.styles.colors.Color’>

contourW

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

extrusionClr

Values must be of type <class ‘openpyxl.styles.colors.Color’>

extrusionH

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
prstMaterial

Value must be one of {‘legacyPlastic’, ‘flat’, ‘legacyWireframe’, ‘legacyMetal’, ‘clear’, ‘legacyMatte’, ‘metal’, ‘warmMatte’, ‘dkEdge’, ‘softmetal’, ‘plastic’, ‘matte’, ‘powder’, ‘translucentPowder’, ‘softEdge’}

z

Values must be of type <class ‘openpyxl.descriptors.base.Integer’>

class openpyxl.drawing.geometry.ShapeStyle(lnRef=None, fillRef=None, effectRef=None, fontRef=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

effectRef

Values must be of type <class ‘openpyxl.drawing.geometry.StyleMatrixReference’>

fillRef

Values must be of type <class ‘openpyxl.drawing.geometry.StyleMatrixReference’>

fontRef

Values must be of type <class ‘openpyxl.drawing.geometry.FontReference’>

lnRef

Values must be of type <class ‘openpyxl.drawing.geometry.StyleMatrixReference’>

class openpyxl.drawing.geometry.SphereCoords(lat=None, lon=None, rev=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

lat

Values must be of type <class ‘int’>

lon

Values must be of type <class ‘int’>

rev

Values must be of type <class ‘int’>

tagname = 'sphereCoords'
class openpyxl.drawing.geometry.StyleMatrixReference(idx=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

idx

Values must be of type <class ‘int’>

class openpyxl.drawing.geometry.Transform2D(rot=None, flipH=None, flipV=None, off=None, ext=None, chOff=None, chExt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chExt

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

chOff

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

ext

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

flipH

Values must be of type <class ‘bool’>

flipV

Values must be of type <class ‘bool’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
off

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

rot

Values must be of type <class ‘int’>

tagname = 'xfrm'
class openpyxl.drawing.geometry.Vector3D(dx=None, dy=None, dz=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dx

Values must be of type <class ‘int’>

dy

Values must be of type <class ‘int’>

dz

Values must be of type <class ‘int’>

tagname = 'vector'
openpyxl.drawing.graphic module
class openpyxl.drawing.graphic.GraphicData(uri='http://schemas.openxmlformats.org/drawingml/2006/chart', chart=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chart

Values must be of type <class ‘openpyxl.drawing.relation.ChartRelation’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'graphicData'
uri

Values must be of type <class ‘str’>

class openpyxl.drawing.graphic.GraphicFrame(nvGraphicFramePr=None, xfrm=None, graphic=None, macro=None, fPublished=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fPublished

Values must be of type <class ‘bool’>

graphic

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicObject’>

macro

Values must be of type <class ‘str’>

nvGraphicFramePr

Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualGraphicFrame’>

tagname = 'graphicFrame'
xfrm

Values must be of type <class ‘openpyxl.drawing.xdr.XDRTransform2D’>

class openpyxl.drawing.graphic.GraphicFrameLocking(noGrp=None, noDrilldown=None, noSelect=None, noChangeAspect=None, noMove=None, noResize=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

noChangeAspect

Values must be of type <class ‘bool’>

noDrilldown

Values must be of type <class ‘bool’>

noGrp

Values must be of type <class ‘bool’>

noMove

Values must be of type <class ‘bool’>

noResize

Values must be of type <class ‘bool’>

noSelect

Values must be of type <class ‘bool’>

class openpyxl.drawing.graphic.GraphicObject(graphicData=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

graphicData

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicData’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'graphic'
class openpyxl.drawing.graphic.GroupShape(nvGrpSpPr=None, grpSpPr=None, pic=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

grpSpPr

Values must be of type <class ‘openpyxl.drawing.properties.GroupShapeProperties’>

nonVisualProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

nvGrpSpPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualGroupShape’>

pic

Values must be of type <class ‘openpyxl.drawing.picture.PictureFrame’>

visualProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.drawing.graphic.NonVisualGraphicFrame(cNvPr=None, cNvGraphicFramePr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cNvGraphicFramePr

Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualGraphicFrameProperties’>

cNvPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingProps’>

tagname = 'nvGraphicFramePr'
class openpyxl.drawing.graphic.NonVisualGraphicFrameProperties(graphicFrameLocks=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

graphicFrameLocks

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicFrameLocking’>

tagname = 'cNvGraphicFramePr'
openpyxl.drawing.image module
class openpyxl.drawing.image.Image(img)[source]

Bases: object

Image in a spreadsheet

anchor = 'A1'
path
openpyxl.drawing.line module
class openpyxl.drawing.line.DashStop(d=0, sp=0)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

d

Values must be of type <class ‘int’>

length

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
sp

Values must be of type <class ‘int’>

space

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'ds'
class openpyxl.drawing.line.DashStopList(ds=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ds

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.drawing.line.LineEndProperties(type=None, w=None, len=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

len

Value must be one of {‘lg’, ‘sm’, ‘med’}

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'end'
type

Value must be one of {‘oval’, ‘stealth’, ‘arrow’, ‘diamond’, ‘triangle’, ‘none’}

w

Value must be one of {‘lg’, ‘sm’, ‘med’}

class openpyxl.drawing.line.LineProperties(w=None, cap=None, cmpd=None, algn=None, noFill=None, solidFill=None, gradFill=None, pattFill=None, prstDash=None, custDash=None, round=None, bevel=None, miter=None, headEnd=None, tailEnd=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algn

Value must be one of {‘ctr’, ‘in’}

bevel

Values must be of type <class ‘bool’>

cap

Value must be one of {‘sq’, ‘flat’, ‘rnd’}

cmpd

Value must be one of {‘thinThick’, ‘dbl’, ‘tri’, ‘thickThin’, ‘sng’}

custDash

Values must be of type <class ‘openpyxl.drawing.line.DashStop’>

dashStyle

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gradFill

Values must be of type <class ‘openpyxl.drawing.fill.GradientFillProperties’>

headEnd

Values must be of type <class ‘openpyxl.drawing.line.LineEndProperties’>

miter

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noFill

Values must be of type <class ‘bool’>

pattFill

Values must be of type <class ‘openpyxl.drawing.fill.PatternFillProperties’>

prstDash

Value must be one of {‘lgDashDotDot’, ‘lgDashDot’, ‘dash’, ‘sysDot’, ‘solid’, ‘sysDashDot’, ‘dot’, ‘lgDash’, ‘dashDot’, ‘sysDashDotDot’, ‘sysDash’}

round

Values must be of type <class ‘bool’>

solidFill

Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>

tagname = 'ln'
tailEnd

Values must be of type <class ‘openpyxl.drawing.line.LineEndProperties’>

w

Values must be of type <class ‘float’>

width

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

openpyxl.drawing.picture module
class openpyxl.drawing.picture.NonVisualPictureProperties(preferRelativeResize=None, picLocks=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

picLocks

Values must be of type <class ‘openpyxl.drawing.picture.PictureLocking’>

preferRelativeResize

Values must be of type <class ‘bool’>

tagname = 'cNvPicPr'
class openpyxl.drawing.picture.PictureFrame(macro=None, fPublished=None, nvPicPr=None, blipFill=None, spPr=None, style=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blipFill

Values must be of type <class ‘openpyxl.drawing.fill.BlipFillProperties’>

fPublished

Values must be of type <class ‘bool’>

graphicalProperties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

macro

Values must be of type <class ‘str’>

nvPicPr

Values must be of type <class ‘openpyxl.drawing.picture.PictureNonVisual’>

spPr

Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>

style

Values must be of type <class ‘openpyxl.drawing.geometry.ShapeStyle’>

tagname = 'pic'
class openpyxl.drawing.picture.PictureLocking(noCrop=None, noGrp=None, noSelect=None, noRot=None, noChangeAspect=None, noMove=None, noResize=None, noEditPoints=None, noAdjustHandles=None, noChangeArrowheads=None, noChangeShapeType=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noAdjustHandles

Values must be of type <class ‘bool’>

noChangeArrowheads

Values must be of type <class ‘bool’>

noChangeAspect

Values must be of type <class ‘bool’>

noChangeShapeType

Values must be of type <class ‘bool’>

noCrop

Values must be of type <class ‘bool’>

noEditPoints

Values must be of type <class ‘bool’>

noGrp

Values must be of type <class ‘bool’>

noMove

Values must be of type <class ‘bool’>

noResize

Values must be of type <class ‘bool’>

noRot

Values must be of type <class ‘bool’>

noSelect

Values must be of type <class ‘bool’>

tagname = 'picLocks'
class openpyxl.drawing.picture.PictureNonVisual(cNvPr=None, cNvPicPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cNvPicPr

Values must be of type <class ‘openpyxl.drawing.picture.NonVisualPictureProperties’>

cNvPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingProps’>

tagname = 'nvPicPr'
openpyxl.drawing.properties module
class openpyxl.drawing.properties.GroupLocking(noGrp=None, noUngrp=None, noSelect=None, noRot=None, noChangeAspect=None, noChangeArrowheads=None, noMove=None, noResize=None, noEditPoints=None, noAdjustHandles=None, noChangeShapeType=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noAdjustHandles

Values must be of type <class ‘bool’>

noChangeArrowheads

Values must be of type <class ‘bool’>

noChangeAspect

Values must be of type <class ‘bool’>

noChangeShapeType

Values must be of type <class ‘bool’>

noEditPoints

Values must be of type <class ‘bool’>

noGrp

Values must be of type <class ‘bool’>

noMove

Values must be of type <class ‘bool’>

noResize

Values must be of type <class ‘bool’>

noRot

Values must be of type <class ‘bool’>

noSelect

Values must be of type <class ‘bool’>

noUngrp

Values must be of type <class ‘bool’>

tagname = 'grpSpLocks'
class openpyxl.drawing.properties.GroupShapeProperties(bwMode=None, xfrm=None, scene3d=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bwMode

Value must be one of {‘hidden’, ‘clr’, ‘invGray’, ‘ltGray’, ‘blackGray’, ‘white’, ‘grayWhite’, ‘auto’, ‘blackWhite’, ‘black’, ‘gray’}

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

scene3d

Values must be of type <class ‘openpyxl.drawing.geometry.Scene3D’>

tagname = 'grpSpPr'
xfrm

Values must be of type <class ‘openpyxl.drawing.geometry.GroupTransform2D’>

class openpyxl.drawing.properties.NonVisualDrawingProps(id=None, name=None, descr=None, hidden=None, title=None, hlinkClick=None, hlinkHover=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

descr

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

hidden

Values must be of type <class ‘bool’>

hlinkClick

Values must be of type <class ‘openpyxl.drawing.text.Hyperlink’>

hlinkHover

Values must be of type <class ‘openpyxl.drawing.text.Hyperlink’>

id

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

tagname = 'cNvPr'
title

Values must be of type <class ‘str’>

class openpyxl.drawing.properties.NonVisualDrawingShapeProps(spLocks=None, txBox=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

spLocks

Values must be of type <class ‘openpyxl.drawing.properties.GroupLocking’>

tagname = 'cNvSpPr'
txBax

Values must be of type <class ‘bool’>

class openpyxl.drawing.properties.NonVisualGroupDrawingShapeProps(grpSpLocks=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

grpSpLocks

Values must be of type <class ‘openpyxl.drawing.properties.GroupLocking’>

tagname = 'cNvGrpSpPr'
class openpyxl.drawing.properties.NonVisualGroupShape(cNvPr=None, cNvGrpSpPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cNvGrpSpPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualGroupDrawingShapeProps’>

cNvPr

Values must be of type <class ‘openpyxl.drawing.properties.NonVisualDrawingProps’>

tagname = 'nvGrpSpPr'
openpyxl.drawing.relation module
class openpyxl.drawing.relation.ChartRelation(id)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/chart'
tagname = 'chart'
openpyxl.drawing.spreadsheet_drawing module
class openpyxl.drawing.spreadsheet_drawing.AbsoluteAnchor(pos=None, ext=None, **kw)[source]

Bases: openpyxl.drawing.spreadsheet_drawing._AnchorBase

clientData

Values must be of type <class ‘openpyxl.drawing.spreadsheet_drawing.AnchorClientData’>

contentPart

Values must be of type <class ‘str’>

cxnSp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

ext

Values must be of type <class ‘openpyxl.drawing.xdr.XDRPositiveSize2D’>

graphicFrame

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicFrame’>

grpSp

Values must be of type <class ‘openpyxl.drawing.graphic.GroupShape’>

pic

Values must be of type <class ‘openpyxl.drawing.picture.PictureFrame’>

pos

Values must be of type <class ‘openpyxl.drawing.xdr.XDRPoint2D’>

sp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

tagname = 'absoluteAnchor'
class openpyxl.drawing.spreadsheet_drawing.AnchorClientData(fLocksWithSheet=None, fPrintsWithSheet=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fLocksWithSheet

Values must be of type <class ‘bool’>

fPrintsWithSheet

Values must be of type <class ‘bool’>

class openpyxl.drawing.spreadsheet_drawing.AnchorMarker(col=0, colOff=0, row=0, rowOff=0)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

col

Values must be of type <class ‘int’>

colOff

Values must be of type <class ‘int’>

row

Values must be of type <class ‘int’>

rowOff

Values must be of type <class ‘int’>

tagname = 'marker'
class openpyxl.drawing.spreadsheet_drawing.OneCellAnchor(_from=None, ext=None, **kw)[source]

Bases: openpyxl.drawing.spreadsheet_drawing._AnchorBase

clientData

Values must be of type <class ‘openpyxl.drawing.spreadsheet_drawing.AnchorClientData’>

contentPart

Values must be of type <class ‘str’>

cxnSp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

ext

Values must be of type <class ‘openpyxl.drawing.xdr.XDRPositiveSize2D’>

graphicFrame

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicFrame’>

grpSp

Values must be of type <class ‘openpyxl.drawing.graphic.GroupShape’>

pic

Values must be of type <class ‘openpyxl.drawing.picture.PictureFrame’>

sp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

tagname = 'oneCellAnchor'
class openpyxl.drawing.spreadsheet_drawing.SpreadsheetDrawing(twoCellAnchor=(), oneCellAnchor=(), absoluteAnchor=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

PartName = '/xl/drawings/drawing{0}.xml'
absoluteAnchor

A sequence (list or tuple) that may only contain objects of the declared type

mime_type = 'application/vnd.openxmlformats-officedocument.drawing+xml'
oneCellAnchor

A sequence (list or tuple) that may only contain objects of the declared type

path
tagname = 'wsDr'
twoCellAnchor

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.drawing.spreadsheet_drawing.TwoCellAnchor(editAs=None, _from=None, to=None, **kw)[source]

Bases: openpyxl.drawing.spreadsheet_drawing._AnchorBase

clientData

Values must be of type <class ‘openpyxl.drawing.spreadsheet_drawing.AnchorClientData’>

contentPart

Values must be of type <class ‘str’>

cxnSp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

editAs

Value must be one of {‘absolute’, ‘oneCell’, ‘twoCell’}

graphicFrame

Values must be of type <class ‘openpyxl.drawing.graphic.GraphicFrame’>

grpSp

Values must be of type <class ‘openpyxl.drawing.graphic.GroupShape’>

pic

Values must be of type <class ‘openpyxl.drawing.picture.PictureFrame’>

sp

Values must be of type <class ‘openpyxl.drawing.connector.Shape’>

tagname = 'twoCellAnchor'
to

Values must be of type <class ‘openpyxl.drawing.spreadsheet_drawing.AnchorMarker’>

openpyxl.drawing.text module
class openpyxl.drawing.text.AutonumberBullet(type=None, startAt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

startAt

Values must be of type <class ‘int’>

type

Value must be one of {‘arabic1Minus’, ‘arabic2Minus’, ‘thaiAlphaPeriod’, ‘circleNumWdWhitePlain’, ‘thaiNumPeriod’, ‘alphaLcParenBoth’, ‘arabicPlain’, ‘alphaLcParenR’, ‘alphaLcPeriod’, ‘arabicParenBoth’, ‘romanLcParenR’, ‘hindiNumPeriod’, ‘alphaUcPeriod’, ‘alphaUcParenR’, ‘thaiAlphaParenR’, ‘romanUcPeriod’, ‘hebrew2Minus’, ‘arabicParenR’, ‘ea1ChsPeriod’, ‘thaiNumParenR’, ‘hindiAlpha1Period’, ‘circleNumDbPlain’, ‘ea1ChtPlain’, ‘circleNumWdBlackPlain’, ‘arabicDbPeriod’, ‘ea1JpnChsDbPeriod’, ‘hindiNumParenR’, ‘romanUcParenBoth’, ‘arabicPeriod’, ‘hindiAlphaPeriod’, ‘romanLcPeriod’, ‘thaiAlphaParenBoth’, ‘arabicDbPlain’, ‘ea1JpnKorPlain’, ‘romanUcParenR’, ‘ea1ChtPeriod’, ‘alphaUcParenBoth’, ‘romanLcParenBoth’, ‘ea1ChsPlain’, ‘thaiNumParenBoth’, ‘ea1JpnKorPeriod’}

class openpyxl.drawing.text.CharacterProperties(kumimoji=None, lang=None, altLang=None, sz=None, b=None, i=None, u=None, strike=None, kern=None, cap=None, spc=None, normalizeH=None, baseline=None, noProof=None, dirty=None, err=None, smtClean=None, smtId=None, bmk=None, ln=None, highlight=None, latin=None, ea=None, cs=None, sym=None, hlinkClick=None, hlinkMouseOver=None, rtl=None, extLst=None, noFill=None, solidFill=None, gradFill=None, blipFill=None, pattFill=None, grpFill=None, effectLst=None, effectDag=None, uLnTx=None, uLn=None, uFillTx=None, uFill=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

altLang

Values must be of type <class ‘str’>

b

Values must be of type <class ‘bool’>

baseline

Values must be of type <class ‘int’>

blipFill

Values must be of type <class ‘openpyxl.drawing.fill.BlipFillProperties’>

bmk

Values must be of type <class ‘str’>

cap

Value must be one of {‘small’, ‘all’}

cs

Values must be of type <class ‘openpyxl.drawing.text.Font’>

dirty

Values must be of type <class ‘bool’>

ea

Values must be of type <class ‘openpyxl.drawing.text.Font’>

effectDag

Values must be of type <class ‘openpyxl.drawing.effect.EffectContainer’>

effectLst

Values must be of type <class ‘openpyxl.drawing.effect.EffectList’>

err

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gradFill

Values must be of type <class ‘openpyxl.drawing.fill.GradientFillProperties’>

grpFill

Values must be of type <class ‘bool’>

highlight

Values must be of type <class ‘openpyxl.styles.colors.Color’>

hlinkClick

Values must be of type <class ‘openpyxl.drawing.text.Hyperlink’>

hlinkMouseOver

Values must be of type <class ‘openpyxl.drawing.text.Hyperlink’>

i

Values must be of type <class ‘bool’>

kern

Values must be of type <class ‘int’>

kumimoji

Values must be of type <class ‘bool’>

lang

Values must be of type <class ‘str’>

latin

Values must be of type <class ‘openpyxl.drawing.text.Font’>

ln

Values must be of type <class ‘openpyxl.drawing.line.LineProperties’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noFill

Values must be of type <class ‘bool’>

noProof

Values must be of type <class ‘bool’>

normalizeH

Values must be of type <class ‘bool’>

pattFill

Values must be of type <class ‘openpyxl.drawing.fill.PatternFillProperties’>

rtl

Values must be of type <class ‘bool’>

smtClean

Values must be of type <class ‘bool’>

smtId

Values must be of type <class ‘int’>

solidFill

Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>

spc

Values must be of type <class ‘int’>

strike

Value must be one of {‘noStrike’, ‘dblStrike’, ‘sngStrike’}

sym

Values must be of type <class ‘openpyxl.drawing.text.Font’>

sz

Values must be of type <class ‘float’>

tagname = 'defRPr'
u

Value must be one of {‘dotted’, ‘dotDash’, ‘dbl’, ‘dash’, ‘wavy’, ‘wavyDbl’, ‘dashHeavy’, ‘dottedHeavy’, ‘dotDotDashHeavy’, ‘wavyHeavy’, ‘dashLongHeavy’, ‘dashLong’, ‘words’, ‘dotDotDash’, ‘heavy’, ‘dotDashHeavy’, ‘sng’}

uFill

Values must be of type <class ‘bool’>

uFillTx

Values must be of type <class ‘bool’>

uLn

Values must be of type <class ‘openpyxl.drawing.line.LineProperties’>

uLnTx

Values must be of type <class ‘bool’>

class openpyxl.drawing.text.EmbeddedWAVAudioFile(name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

class openpyxl.drawing.text.Font(typeface=None, panose=None, pitchFamily=None, charset=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

charset

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
panose
pitchFamily

Values must be of type <class ‘float’>

tagname = 'latin'
typeface

Values must be of type <class ‘str’>

class openpyxl.drawing.text.GeomGuide(name=None, fmla=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fmla

Values must be of type <class ‘str’>

name

Values must be of type <class ‘str’>

class openpyxl.drawing.text.GeomGuideList(gd=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

gd

A sequence (list or tuple) that may only contain objects of the declared type

Bases: openpyxl.descriptors.serialisable.Serialisable

action

Values must be of type <class ‘str’>

endSnd

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

highlightClick

Values must be of type <class ‘bool’>

history

Values must be of type <class ‘bool’>

id

Values must be of type <class ‘str’>

invalidUrl

Values must be of type <class ‘str’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
snd

Values must be of type <class ‘openpyxl.drawing.text.EmbeddedWAVAudioFile’>

tagname = 'hlinkClick'
tgtFrame

Values must be of type <class ‘str’>

tooltip

Values must be of type <class ‘str’>

class openpyxl.drawing.text.LineBreak(rPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
rPr

Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>

tagname = 'br'
class openpyxl.drawing.text.ListStyle(defPPr=None, lvl1pPr=None, lvl2pPr=None, lvl3pPr=None, lvl4pPr=None, lvl5pPr=None, lvl6pPr=None, lvl7pPr=None, lvl8pPr=None, lvl9pPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

defPPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

lvl1pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl2pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl3pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl4pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl5pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl6pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl7pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl8pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

lvl9pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'lstStyle'
class openpyxl.drawing.text.Paragraph(pPr=None, endParaRPr=None, r=None, br=None, fld=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

br

Values must be of type <class ‘openpyxl.drawing.text.LineBreak’>

endParaRPr

Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>

fld

Values must be of type <class ‘openpyxl.drawing.text.TextField’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

properties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

r

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'p'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.drawing.text.ParagraphProperties(marL=None, marR=None, lvl=None, indent=None, algn=None, defTabSz=None, rtl=None, eaLnBrk=None, fontAlgn=None, latinLnBrk=None, hangingPunct=None, lnSpc=None, spcBef=None, spcAft=None, tabLst=None, defRPr=None, extLst=None, buClrTx=None, buClr=None, buSzTx=None, buSzPct=None, buSzPts=None, buFontTx=None, buFont=None, buNone=None, buAutoNum=None, buChar=None, buBlip=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algn

Value must be one of {‘thaiDist’, ‘just’, ‘ctr’, ‘r’, ‘l’, ‘justLow’, ‘dist’}

buAutoNum

Values must be of type <class ‘bool’>

buBlip

Values must be of type <class ‘openpyxl.drawing.fill.Blip’>

buChar

Values must be of type <class ‘str’>

buClr

Values must be of type <class ‘openpyxl.styles.colors.Color’>

buClrTx

Values must be of type <class ‘bool’>

buFont

Values must be of type <class ‘openpyxl.drawing.text.Font’>

buFontTx

Values must be of type <class ‘bool’>

buNone

Values must be of type <class ‘bool’>

buSzPct

Values must be of type <class ‘int’>

buSzPts

Values must be of type <class ‘int’>

buSzTx

Values must be of type <class ‘bool’>

defRPr

Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>

defTabSz

Values must be of type <class ‘int’>

eaLnBrk

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fontAlgn

Value must be one of {‘ctr’, ‘auto’, ‘t’, ‘b’, ‘base’}

hangingPunct

Values must be of type <class ‘bool’>

indent

Values must be of type <class ‘int’>

latinLnBrk

Values must be of type <class ‘bool’>

lnSpc

Values must be of type <class ‘openpyxl.drawing.text.Spacing’>

lvl

Values must be of type <class ‘int’>

marL

Values must be of type <class ‘int’>

marR

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
rtl

Values must be of type <class ‘bool’>

spcAft

Values must be of type <class ‘openpyxl.drawing.text.Spacing’>

spcBef

Values must be of type <class ‘openpyxl.drawing.text.Spacing’>

tabLst

Values must be of type <class ‘openpyxl.drawing.text.TabStopList’>

tagname = 'pPr'
class openpyxl.drawing.text.PresetTextShape(prst=None, avLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

avLst

Values must be of type <class ‘openpyxl.drawing.text.GeomGuideList’>

prst

Values must be of type <openpyxl.descriptors.base.Set object at 0x7f4788886990>

class openpyxl.drawing.text.RegularTextRun(rPr=None, t='')[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
properties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

rPr

Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>

t

Values must be of type <class ‘str’>

tagname = 'r'
value

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.drawing.text.RichTextProperties(rot=None, spcFirstLastPara=None, vertOverflow=None, horzOverflow=None, vert=None, wrap=None, lIns=None, tIns=None, rIns=None, bIns=None, numCol=None, spcCol=None, rtlCol=None, fromWordArt=None, anchor=None, anchorCtr=None, forceAA=None, upright=None, compatLnSpc=None, prstTxWarp=None, scene3d=None, extLst=None, noAutofit=None, normAutofit=None, spAutoFit=None, flatTx=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

anchor

Value must be one of {‘just’, ‘ctr’, ‘dist’, ‘t’, ‘b’}

anchorCtr

Values must be of type <class ‘bool’>

bIns

Values must be of type <class ‘int’>

compatLnSpc

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

flatTx

Values must be of type <class ‘int’>

forceAA

Values must be of type <class ‘bool’>

fromWordArt

Values must be of type <class ‘bool’>

horzOverflow

Value must be one of {‘overflow’, ‘clip’}

lIns

Values must be of type <class ‘int’>

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
noAutofit

Values must be of type <class ‘bool’>

normAutofit

Values must be of type <class ‘bool’>

numCol

Values must be of type <class ‘int’>

prstTxWarp

Values must be of type <class ‘openpyxl.drawing.text.PresetTextShape’>

rIns

Values must be of type <class ‘int’>

rot

Values must be of type <class ‘int’>

rtlCol

Values must be of type <class ‘bool’>

scene3d

Values must be of type <class ‘openpyxl.drawing.geometry.Scene3D’>

spAutoFit

Values must be of type <class ‘bool’>

spcCol

Values must be of type <class ‘int’>

spcFirstLastPara

Values must be of type <class ‘bool’>

tIns

Values must be of type <class ‘int’>

tagname = 'bodyPr'
upright

Values must be of type <class ‘bool’>

vert

Value must be one of {‘wordArtVertRtl’, ‘wordArtVert’, ‘horz’, ‘mongolianVert’, ‘vert’, ‘eaVert’, ‘vert270’}

vertOverflow

Value must be one of {‘overflow’, ‘ellipsis’, ‘clip’}

wrap

Value must be one of {‘square’, ‘none’}

class openpyxl.drawing.text.Spacing(spcPct=None, spcPts=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

spcPct

Values must be of type <class ‘int’>

spcPts

Values must be of type <class ‘int’>

class openpyxl.drawing.text.TabStop(pos=None, algn=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algn

Values must be of type <openpyxl.descriptors.base.Set object at 0x7f478887e4d0>

pos

Values must be of type <class ‘openpyxl.descriptors.base.Integer’>

class openpyxl.drawing.text.TabStopList(tab=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tab

Values must be of type <class ‘openpyxl.drawing.text.TabStop’>

class openpyxl.drawing.text.TextField(id=None, type=None, rPr=None, pPr=None, t=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

pPr

Values must be of type <class ‘openpyxl.drawing.text.ParagraphProperties’>

rPr

Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>

t

Values must be of type <class ‘str’>

type

Values must be of type <class ‘str’>

class openpyxl.drawing.text.TextNormalAutofit(fontScale=None, lnSpcReduction=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fontScale

Values must be of type <class ‘int’>

lnSpcReduction

Values must be of type <class ‘int’>

openpyxl.drawing.xdr module

Spreadsheet Drawing has some copies of Drawing ML elements

class openpyxl.drawing.xdr.XDRPoint2D(x=None, y=None)[source]

Bases: openpyxl.drawing.geometry.Point2D

namespace = None
x

Values must be of type <class ‘int’>

y

Values must be of type <class ‘int’>

class openpyxl.drawing.xdr.XDRPositiveSize2D(cx=None, cy=None)[source]

Bases: openpyxl.drawing.geometry.PositiveSize2D

cx

Values must be of type <class ‘int’>

cy

Values must be of type <class ‘int’>

namespace = None
class openpyxl.drawing.xdr.XDRTransform2D(rot=None, flipH=None, flipV=None, off=None, ext=None, chOff=None, chExt=None)[source]

Bases: openpyxl.drawing.geometry.Transform2D

chExt

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

chOff

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

ext

Values must be of type <class ‘openpyxl.drawing.geometry.PositiveSize2D’>

flipH

Values must be of type <class ‘bool’>

flipV

Values must be of type <class ‘bool’>

namespace = None
off

Values must be of type <class ‘openpyxl.drawing.geometry.Point2D’>

rot

Values must be of type <class ‘int’>

openpyxl.formatting package
Submodules
openpyxl.formatting.formatting module
class openpyxl.formatting.formatting.ConditionalFormatting(sqref=(), pivot=None, cfRule=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cells

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

cfRule

A sequence (list or tuple) that may only contain objects of the declared type

pivot

Values must be of type <class ‘bool’>

rules

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

sqref

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

tagname = 'conditionalFormatting'
class openpyxl.formatting.formatting.ConditionalFormattingList[source]

Bases: object

Conditional formatting rules.

add(range_string, cfRule)[source]

Add a rule such as ColorScaleRule, FormulaRule or CellIsRule

The priority will be added automatically.

openpyxl.formatting.rule module
openpyxl.formatting.rule.CellIsRule(operator=None, formula=None, stopIfTrue=None, font=None, border=None, fill=None)[source]

Conditional formatting rule based on cell contents.

class openpyxl.formatting.rule.ColorScale(cfvo=None, color=None)[source]

Bases: openpyxl.formatting.rule.RuleType

color

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'colorScale'
openpyxl.formatting.rule.ColorScaleRule(start_type=None, start_value=None, start_color=None, mid_type=None, mid_value=None, mid_color=None, end_type=None, end_value=None, end_color=None)[source]

Backwards compatibility

class openpyxl.formatting.rule.DataBar(minLength=None, maxLength=None, showValue=None, cfvo=None, color=None)[source]

Bases: openpyxl.formatting.rule.RuleType

color

Values must be of type <class ‘openpyxl.styles.colors.Color’>

maxLength

Values must be of type <class ‘int’>

minLength

Values must be of type <class ‘int’>

showValue

Values must be of type <class ‘bool’>

tagname = 'dataBar'
openpyxl.formatting.rule.DataBarRule(start_type=None, start_value=None, end_type=None, end_value=None, color=None, showValue=None, minLength=None, maxLength=None)[source]
class openpyxl.formatting.rule.FormatObject(type, val=None, gte=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

gte

Values must be of type <class ‘bool’>

tagname = 'cfvo'
type

Value must be one of {‘formula’, ‘num’, ‘percentile’, ‘min’, ‘max’, ‘percent’}

val

Values must be of type <class ‘float’>

openpyxl.formatting.rule.FormulaRule(formula=None, stopIfTrue=None, font=None, border=None, fill=None)[source]

Conditional formatting with custom differential style

class openpyxl.formatting.rule.IconSet(iconSet=None, showValue=None, percent=None, reverse=None, cfvo=None)[source]

Bases: openpyxl.formatting.rule.RuleType

iconSet

Value must be one of {‘3ArrowsGray’, ‘3Symbols2’, ‘3Flags’, ‘3Symbols’, ‘3Arrows’, ‘4ArrowsGray’, ‘5Arrows’, ‘5Rating’, ‘5Quarters’, ‘4TrafficLights’, ‘4Arrows’, ‘3TrafficLights2’, ‘3Signs’, ‘5ArrowsGray’, ‘4RedToBlack’, ‘3TrafficLights1’, ‘4Rating’}

percent

Values must be of type <class ‘bool’>

reverse

Values must be of type <class ‘bool’>

showValue

Values must be of type <class ‘bool’>

tagname = 'iconSet'
openpyxl.formatting.rule.IconSetRule(icon_style=None, type=None, values=None, showValue=None, percent=None, reverse=None)[source]

Convenience function for creating icon set rules

class openpyxl.formatting.rule.Rule(type, dxfId=None, priority=0, stopIfTrue=None, aboveAverage=None, percent=None, bottom=None, operator=None, text=None, timePeriod=None, rank=None, stdDev=None, equalAverage=None, formula=(), colorScale=None, dataBar=None, iconSet=None, extLst=None, dxf=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

aboveAverage

Values must be of type <class ‘bool’>

bottom

Values must be of type <class ‘bool’>

colorScale

Values must be of type <class ‘openpyxl.formatting.rule.ColorScale’>

dataBar

Values must be of type <class ‘openpyxl.formatting.rule.DataBar’>

dxf

Values must be of type <class ‘openpyxl.styles.differential.DifferentialStyle’>

dxfId

Values must be of type <class ‘int’>

equalAverage

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

formula

A sequence (list or tuple) that may only contain objects of the declared type

iconSet

Values must be of type <class ‘openpyxl.formatting.rule.IconSet’>

operator

Value must be one of {‘greaterThanOrEqual’, ‘notContains’, ‘equal’, ‘between’, ‘lessThan’, ‘beginsWith’, ‘containsText’, ‘notBetween’, ‘greaterThan’, ‘lessThanOrEqual’, ‘endsWith’, ‘notEqual’}

percent

Values must be of type <class ‘bool’>

priority

Values must be of type <class ‘int’>

rank

Values must be of type <class ‘int’>

stdDev

Values must be of type <class ‘int’>

stopIfTrue

Values must be of type <class ‘bool’>

tagname = 'cfRule'
text

Values must be of type <class ‘str’>

timePeriod

Value must be one of {‘last7Days’, ‘lastWeek’, ‘lastMonth’, ‘today’, ‘thisMonth’, ‘nextWeek’, ‘thisWeek’, ‘nextMonth’, ‘tomorrow’, ‘yesterday’}

type

Value must be one of {‘colorScale’, ‘dataBar’, ‘timePeriod’, ‘notContainsErrors’, ‘containsErrors’, ‘beginsWith’, ‘cellIs’, ‘uniqueValues’, ‘containsText’, ‘containsBlanks’, ‘iconSet’, ‘notContainsText’, ‘notContainsBlanks’, ‘top10’, ‘duplicateValues’, ‘aboveAverage’, ‘endsWith’, ‘expression’}

class openpyxl.formatting.rule.RuleType[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cfvo

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.formatting.rule.ValueDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Float

Expected type depends upon type attribute of parent :-(

Most values should be numeric BUT they can also be cell references

openpyxl.packaging package

Stuff related to Office OpenXML packaging: relationships, archive, content types.

Submodules
openpyxl.packaging.core module
class openpyxl.packaging.core.DocumentProperties(category=None, contentStatus=None, keywords=None, lastModifiedBy=None, lastPrinted=None, revision=None, version=None, created=None, creator='openpyxl', description=None, identifier=None, language=None, modified=None, subject=None, title=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

High-level properties of the document. Defined in ECMA-376 Par2 Annex D

category

Values must be of type <class ‘str’>

contentStatus

Values must be of type <class ‘str’>

created

Values must be of type <class ‘datetime.datetime’>

creator

Values must be of type <class ‘str’>

description

Values must be of type <class ‘str’>

identifier

Values must be of type <class ‘str’>

keywords

Values must be of type <class ‘str’>

language

Values must be of type <class ‘str’>

lastModifiedBy

Values must be of type <class ‘str’>

lastPrinted

Values must be of type <class ‘datetime.datetime’>

last_modified_by

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

modified

Values must be of type <class ‘datetime.datetime’>

namespace = 'http://schemas.openxmlformats.org/package/2006/metadata/core-properties'
revision

Values must be of type <class ‘str’>

subject

Values must be of type <class ‘str’>

tagname = 'coreProperties'
title

Values must be of type <class ‘str’>

version

Values must be of type <class ‘str’>

class openpyxl.packaging.core.NestedDateTime(*args, **kw)[source]

Bases: openpyxl.descriptors.base.DateTime, openpyxl.descriptors.nested.NestedText

expected_type

alias of datetime.datetime

to_tree(tagname=None, value=None, namespace=None)[source]
class openpyxl.packaging.core.QualifiedDateTime(*args, **kw)[source]

Bases: openpyxl.packaging.core.NestedDateTime

In certain situations Excel will complain if the additional type attribute isn’t set

to_tree(tagname=None, value=None, namespace=None)[source]
openpyxl.packaging.custom module

Implementation of custom properties see § 22.3 in the specification

class openpyxl.packaging.custom.BoolProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘bool’>

class openpyxl.packaging.custom.CustomPropertyList[source]

Bases: openpyxl.descriptors.Strict

append(prop)[source]
classmethod from_tree(tree)[source]

Create list from OOXML element

names

List of property names

props

A sequence (list or tuple) that may only contain objects of the declared type

to_tree()[source]
class openpyxl.packaging.custom.DateTimeProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘datetime.datetime’>

class openpyxl.packaging.custom.FloatProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘float’>

class openpyxl.packaging.custom.IntProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘int’>

class openpyxl.packaging.custom.LinkProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘str’>

class openpyxl.packaging.custom.NestedBoolText(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Bool, openpyxl.descriptors.nested.NestedText

Descriptor for handling nested elements with the value stored in the text part

class openpyxl.packaging.custom.StringProperty(name, value)[source]

Bases: openpyxl.packaging.custom._TypedProperty

value

Values must be of type <class ‘str’>

openpyxl.packaging.extended module
class openpyxl.packaging.extended.DigSigBlob[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.packaging.extended.ExtendedProperties(Template=None, Manager=None, Company=None, Pages=None, Words=None, Characters=None, PresentationFormat=None, Lines=None, Paragraphs=None, Slides=None, Notes=None, TotalTime=None, HiddenSlides=None, MMClips=None, ScaleCrop=None, HeadingPairs=None, TitlesOfParts=None, LinksUpToDate=None, CharactersWithSpaces=None, SharedDoc=None, HyperlinkBase=None, HLinks=None, HyperlinksChanged=None, DigSig=None, Application='Microsoft Excel', AppVersion=None, DocSecurity=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

See 22.2

Most of this is irrelevant

AppVersion

Values must be of type <class ‘str’>

Application

Values must be of type <class ‘str’>

Characters

Values must be of type <class ‘int’>

CharactersWithSpaces

Values must be of type <class ‘int’>

Company

Values must be of type <class ‘str’>

DigSig

Values must be of type <class ‘openpyxl.packaging.extended.DigSigBlob’>

DocSecurity

Values must be of type <class ‘int’>

Values must be of type <class ‘openpyxl.packaging.extended.VectorVariant’>

HeadingPairs

Values must be of type <class ‘openpyxl.packaging.extended.VectorVariant’>

HiddenSlides

Values must be of type <class ‘int’>

HyperlinkBase

Values must be of type <class ‘str’>

HyperlinksChanged

Values must be of type <class ‘bool’>

Lines

Values must be of type <class ‘int’>

LinksUpToDate

Values must be of type <class ‘bool’>

MMClips

Values must be of type <class ‘int’>

Manager

Values must be of type <class ‘str’>

Notes

Values must be of type <class ‘int’>

Pages

Values must be of type <class ‘int’>

Paragraphs

Values must be of type <class ‘int’>

PresentationFormat

Values must be of type <class ‘str’>

ScaleCrop

Values must be of type <class ‘bool’>

SharedDoc

Values must be of type <class ‘bool’>

Slides

Values must be of type <class ‘int’>

Template

Values must be of type <class ‘str’>

TitlesOfParts

Values must be of type <class ‘openpyxl.packaging.extended.VectorLpstr’>

TotalTime

Values must be of type <class ‘int’>

Words

Values must be of type <class ‘int’>

tagname = 'Properties'
to_tree()[source]
class openpyxl.packaging.extended.VectorLpstr[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

class openpyxl.packaging.extended.VectorVariant[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

openpyxl.packaging.extended.get_version()[source]
openpyxl.packaging.interface module
class openpyxl.packaging.interface.ISerialisableFile[source]

Bases: abc.ABC

Interface for Serialisable classes that represent files in the archive

id

Object id making it unique

openpyxl.packaging.manifest module

File manifest

class openpyxl.packaging.manifest.FileExtension(Extension, ContentType)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ContentType

Values must be of type <class ‘str’>

Extension

Values must be of type <class ‘str’>

tagname = 'Default'
class openpyxl.packaging.manifest.Manifest(Default=(), Override=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Default

A sequence (list or tuple) that may only contain objects of the declared type

Override

A sequence (list or tuple) that may only contain objects of the declared type

append(obj)[source]

Add content object to the package manifest # needs a contract…

extensions

Map content types to file extensions Skip parts without extensions

filenames
find(content_type)[source]

Find specific content-type

findall(content_type)[source]

Find all elements of a specific content-type

path = '[Content_Types].xml'
tagname = 'Types'
to_tree()[source]

Custom serialisation method to allow setting a default namespace

class openpyxl.packaging.manifest.Override(PartName, ContentType)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ContentType

Values must be of type <class ‘str’>

PartName

Values must be of type <class ‘str’>

tagname = 'Override'
openpyxl.packaging.relationship module
class openpyxl.packaging.relationship.Relationship(Id=None, Type=None, type=None, Target=None, TargetMode=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Represents many kinds of relationships.

Id

Values must be of type <class ‘str’>

Target

Values must be of type <class ‘str’>

TargetMode

Values must be of type <class ‘str’>

Type

Values must be of type <class ‘str’>

id

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'Relationship'
target

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.packaging.relationship.RelationshipList(Relationship=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Relationship

A sequence (list or tuple) that may only contain objects of the declared type

append(value)[source]
find(content_type)[source]

Find relationships by content-type NB. these content-types namespaced objects and different to the MIME-types in the package manifest :-(

tagname = 'Relationships'
to_tree()[source]
openpyxl.packaging.relationship.get_dependents(archive, filename)[source]

Normalise dependency file paths to absolute ones

Relative paths are relative to parent object

openpyxl.packaging.relationship.get_rel(archive, deps, id=None, cls=None)[source]

Get related object based on id or rel_type

openpyxl.packaging.relationship.get_rels_path(path)[source]

Convert relative path to absolutes that can be loaded from a zip archive. The path to be passed in is that of containing object (workbook, worksheet, etc.)

openpyxl.packaging.workbook module
class openpyxl.packaging.workbook.ChildSheet(name=None, sheetId=None, state='visible', id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Represents a reference to a worksheet or chartsheet in workbook.xml

It contains the title, order and state but only an indirect reference to the objects themselves.

id

Values must be of type <class ‘str’>

name

Values must be of type <class ‘str’>

sheetId

Values must be of type <class ‘int’>

state

Value must be one of {‘visible’, ‘hidden’, ‘veryHidden’}

tagname = 'sheet'
class openpyxl.packaging.workbook.FileRecoveryProperties(autoRecover=None, crashSave=None, dataExtractLoad=None, repairLoad=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoRecover

Values must be of type <class ‘bool’>

crashSave

Values must be of type <class ‘bool’>

dataExtractLoad

Values must be of type <class ‘bool’>

repairLoad

Values must be of type <class ‘bool’>

tagname = 'fileRecoveryPr'
class openpyxl.packaging.workbook.PivotCache(cacheId=None, id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cacheId

Values must be of type <class ‘int’>

id

Values must be of type <class ‘str’>

tagname = 'pivotCache'
class openpyxl.packaging.workbook.WorkbookPackage(conformance=None, fileVersion=None, fileSharing=None, workbookPr=None, workbookProtection=None, bookViews=(), sheets=(), functionGroups=None, externalReferences=(), definedNames=None, calcPr=None, oleSize=None, customWorkbookViews=(), pivotCaches=(), smartTagPr=None, smartTagTypes=None, webPublishing=None, fileRecoveryPr=None, webPublishObjects=None, extLst=None, Ignorable=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Represent the workbook file in the archive

Ignorable

Values must be of type <class ‘str’>

active
bookViews

Wrap a sequence in an containing object

calcPr

Values must be of type <class ‘openpyxl.workbook.properties.CalcProperties’>

conformance

Value must be one of {‘transitional’, ‘strict’}

customWorkbookViews

Wrap a sequence in an containing object

definedNames

Values must be of type <class ‘openpyxl.workbook.defined_name.DefinedNameList’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

externalReferences

Wrap a sequence in an containing object

fileRecoveryPr

Values must be of type <class ‘openpyxl.packaging.workbook.FileRecoveryProperties’>

fileSharing

Values must be of type <class ‘openpyxl.workbook.protection.FileSharing’>

fileVersion

Values must be of type <class ‘openpyxl.workbook.properties.FileVersion’>

functionGroups

Values must be of type <class ‘openpyxl.workbook.function_group.FunctionGroupList’>

oleSize

Values must be of type <class ‘str’>

pivotCaches

Wrap a sequence in an containing object

properties

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

sheets

Wrap a sequence in an containing object

smartTagPr

Values must be of type <class ‘openpyxl.workbook.smart_tags.SmartTagProperties’>

smartTagTypes

Values must be of type <class ‘openpyxl.workbook.smart_tags.SmartTagList’>

tagname = 'workbook'
to_tree()[source]
webPublishObjects

Values must be of type <class ‘openpyxl.workbook.web.WebPublishObjectList’>

webPublishing

Values must be of type <class ‘openpyxl.workbook.web.WebPublishing’>

workbookPr

Values must be of type <class ‘openpyxl.workbook.properties.WorkbookProperties’>

workbookProtection

Values must be of type <class ‘openpyxl.workbook.protection.WorkbookProtection’>

openpyxl.pivot package
Submodules
openpyxl.pivot.cache module
class openpyxl.pivot.cache.CacheDefinition(invalid=None, saveData=None, refreshOnLoad=None, optimizeMemory=None, enableRefresh=None, refreshedBy=None, refreshedDate=None, refreshedDateIso=None, backgroundQuery=None, missingItemsLimit=None, createdVersion=None, refreshedVersion=None, minRefreshableVersion=None, recordCount=None, upgradeOnRefresh=None, tupleCache=None, supportSubquery=None, supportAdvancedDrill=None, cacheSource=None, cacheFields=(), cacheHierarchies=(), kpis=(), calculatedItems=(), calculatedMembers=(), dimensions=(), measureGroups=(), maps=(), extLst=None, id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

backgroundQuery

Values must be of type <class ‘bool’>

cacheFields

Wrap a sequence in an containing object

cacheHierarchies

Wrap a sequence in an containing object

cacheSource

Values must be of type <class ‘openpyxl.pivot.cache.CacheSource’>

calculatedItems

Wrap a sequence in an containing object

calculatedMembers

Wrap a sequence in an containing object

createdVersion

Values must be of type <class ‘int’>

dimensions

Wrap a sequence in an containing object

enableRefresh

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

id

Values must be of type <class ‘str’>

invalid

Values must be of type <class ‘bool’>

kpis

Wrap a sequence in an containing object

maps

Wrap a sequence in an containing object

measureGroups

Wrap a sequence in an containing object

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml'
minRefreshableVersion

Values must be of type <class ‘int’>

missingItemsLimit

Values must be of type <class ‘int’>

optimizeMemory

Values must be of type <class ‘bool’>

path
recordCount

Values must be of type <class ‘int’>

records = None
refreshOnLoad

Values must be of type <class ‘bool’>

refreshedBy

Values must be of type <class ‘str’>

refreshedDate

Values must be of type <class ‘float’>

refreshedDateIso

Values must be of type <class ‘datetime.datetime’>

refreshedVersion

Values must be of type <class ‘int’>

rel_type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition'
saveData

Values must be of type <class ‘bool’>

supportAdvancedDrill

Values must be of type <class ‘bool’>

supportSubquery

Values must be of type <class ‘bool’>

tagname = 'pivotCacheDefinition'
to_tree()[source]
tupleCache

Values must be of type <class ‘openpyxl.pivot.cache.TupleCache’>

upgradeOnRefresh

Values must be of type <class ‘bool’>

class openpyxl.pivot.cache.CacheField(sharedItems=None, fieldGroup=None, mpMap=None, extLst=None, name=None, caption=None, propertyName=None, serverField=None, uniqueList=True, numFmtId=None, formula=None, sqlType=0, hierarchy=0, level=0, databaseField=True, mappingCount=None, memberPropertyField=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

databaseField

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fieldGroup

Values must be of type <class ‘openpyxl.pivot.cache.FieldGroup’>

formula

Values must be of type <class ‘str’>

hierarchy

Values must be of type <class ‘int’>

level

Values must be of type <class ‘int’>

mappingCount

Values must be of type <class ‘int’>

memberPropertyField

Values must be of type <class ‘bool’>

mpMap

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

numFmtId

Values must be of type <class ‘int’>

propertyName

Values must be of type <class ‘str’>

serverField

Values must be of type <class ‘bool’>

sharedItems

Values must be of type <class ‘openpyxl.pivot.cache.SharedItems’>

sqlType

Values must be of type <class ‘int’>

tagname = 'cacheField'
uniqueList

Values must be of type <class ‘bool’>

class openpyxl.pivot.cache.CacheHierarchy(uniqueName='', caption=None, measure=None, set=None, parentSet=None, iconSet=0, attribute=None, time=None, keyAttribute=None, defaultMemberUniqueName=None, allUniqueName=None, allCaption=None, dimensionUniqueName=None, displayFolder=None, measureGroup=None, measures=None, count=None, oneField=None, memberValueDatatype=None, unbalanced=None, unbalancedGroup=None, hidden=None, fieldsUsage=None, groupLevels=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

allCaption

Values must be of type <class ‘str’>

allUniqueName

Values must be of type <class ‘str’>

attribute

Values must be of type <class ‘bool’>

caption

Values must be of type <class ‘str’>

count

Values must be of type <class ‘int’>

defaultMemberUniqueName

Values must be of type <class ‘str’>

dimensionUniqueName

Values must be of type <class ‘str’>

displayFolder

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fieldsUsage

Values must be of type <class ‘openpyxl.pivot.cache.FieldsUsage’>

groupLevels

Values must be of type <class ‘openpyxl.pivot.cache.GroupLevels’>

hidden

Values must be of type <class ‘bool’>

iconSet

Values must be of type <class ‘int’>

keyAttribute

Values must be of type <class ‘bool’>

measure

Values must be of type <class ‘bool’>

measureGroup

Values must be of type <class ‘str’>

measures

Values must be of type <class ‘bool’>

memberValueDatatype

Values must be of type <class ‘int’>

oneField

Values must be of type <class ‘bool’>

parentSet

Values must be of type <class ‘int’>

set

Values must be of type <class ‘bool’>

tagname = 'cacheHierarchy'
time

Values must be of type <class ‘bool’>

unbalanced

Values must be of type <class ‘bool’>

unbalancedGroup

Values must be of type <class ‘bool’>

uniqueName

Values must be of type <class ‘str’>

class openpyxl.pivot.cache.CacheSource(type=None, connectionId=None, worksheetSource=None, consolidation=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

connectionId

Values must be of type <class ‘int’>

consolidation

Values must be of type <class ‘openpyxl.pivot.cache.Consolidation’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

tagname = 'cacheSource'
type

Value must be one of {‘worksheet’, ‘scenario’, ‘external’, ‘consolidation’}

worksheetSource

Values must be of type <class ‘openpyxl.pivot.cache.WorksheetSource’>

class openpyxl.pivot.cache.CalculatedItem(field=None, formula=None, pivotArea=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

field

Values must be of type <class ‘int’>

formula

Values must be of type <class ‘str’>

pivotArea

Values must be of type <class ‘openpyxl.pivot.table.PivotArea’>

tagname = 'calculatedItem'
class openpyxl.pivot.cache.CalculatedMember(name=None, mdx=None, memberName=None, hierarchy=None, parent=None, solveOrder=None, set=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

hierarchy

Values must be of type <class ‘str’>

mdx

Values must be of type <class ‘str’>

memberName

Values must be of type <class ‘str’>

name

Values must be of type <class ‘str’>

parent

Values must be of type <class ‘str’>

set

Values must be of type <class ‘bool’>

solveOrder

Values must be of type <class ‘int’>

tagname = 'calculatedMember'
class openpyxl.pivot.cache.Consolidation(autoPage=None, pages=(), rangeSets=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoPage

Values must be of type <class ‘bool’>

pages

Wrap a sequence in an containing object

rangeSets

Wrap a sequence in an containing object

tagname = 'consolidation'
class openpyxl.pivot.cache.DiscretePr(count=None, x=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

tagname = 'discretePr'
x

Values must be of type <class ‘int’>

class openpyxl.pivot.cache.FieldGroup(par=None, base=None, rangePr=None, discretePr=None, groupItems=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

base

Values must be of type <class ‘int’>

discretePr

Values must be of type <class ‘openpyxl.pivot.cache.DiscretePr’>

groupItems

Values must be of type <class ‘openpyxl.pivot.cache.GroupItems’>

par

Values must be of type <class ‘int’>

rangePr

Values must be of type <class ‘openpyxl.pivot.cache.RangePr’>

tagname = 'fieldGroup'
class openpyxl.pivot.cache.FieldUsage(x=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'fieldUsage'
x

Values must be of type <class ‘int’>

class openpyxl.pivot.cache.FieldsUsage(count=None, fieldUsage=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

fieldUsage

Values must be of type <class ‘openpyxl.pivot.cache.FieldUsage’>

class openpyxl.pivot.cache.GroupItems(count=None, m=(), n=(), b=(), e=(), s=(), d=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

A sequence (list or tuple) that may only contain objects of the declared type

count
d

A sequence (list or tuple) that may only contain objects of the declared type

e

A sequence (list or tuple) that may only contain objects of the declared type

m

A sequence (list or tuple) that may only contain objects of the declared type

n

A sequence (list or tuple) that may only contain objects of the declared type

s

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'groupItems'
class openpyxl.pivot.cache.GroupLevel(uniqueName=None, caption=None, user=None, customRollUp=None, groups=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

customRollUp

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

groups

Values must be of type <class ‘openpyxl.pivot.cache.Groups’>

tagname = 'groupLevel'
uniqueName

Values must be of type <class ‘str’>

user

Values must be of type <class ‘bool’>

class openpyxl.pivot.cache.GroupLevels(count=None, groupLevel=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

groupLevel

Values must be of type <class ‘openpyxl.pivot.cache.GroupLevel’>

class openpyxl.pivot.cache.GroupMember(uniqueName=None, group=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

group

Values must be of type <class ‘bool’>

tagname = 'groupMember'
uniqueName

Values must be of type <class ‘str’>

class openpyxl.pivot.cache.GroupMembers(count=None, groupMember=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

groupMember

Values must be of type <class ‘openpyxl.pivot.cache.GroupMember’>

class openpyxl.pivot.cache.Groups(count=None, group=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

group

Values must be of type <class ‘openpyxl.pivot.cache.LevelGroup’>

tagname = 'groups'
class openpyxl.pivot.cache.LevelGroup(name=None, uniqueName=None, caption=None, uniqueParent=None, id=None, groupMembers=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

groupMembers

Values must be of type <class ‘openpyxl.pivot.cache.GroupMembers’>

id

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

tagname = 'levelGroup'
uniqueName

Values must be of type <class ‘str’>

uniqueParent

Values must be of type <class ‘str’>

class openpyxl.pivot.cache.MeasureDimensionMap(measureGroup=None, dimension=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dimension

Values must be of type <class ‘int’>

measureGroup

Values must be of type <class ‘int’>

tagname = 'map'
class openpyxl.pivot.cache.MeasureGroup(name=None, caption=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

name

Values must be of type <class ‘str’>

tagname = 'measureGroup'
class openpyxl.pivot.cache.OLAPSet(count=None, maxRank=None, setDefinition=None, sortType=None, queryFailed=None, tpls=None, sortByTuple=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

maxRank

Values must be of type <class ‘int’>

queryFailed

Values must be of type <class ‘bool’>

setDefinition

Values must be of type <class ‘str’>

sortByTuple

Values must be of type <class ‘openpyxl.pivot.fields.TupleList’>

sortType

Value must be one of {‘descendingNatural’, ‘descendingAlpha’, ‘ascending’, ‘descending’, ‘ascendingNatural’, ‘ascendingAlpha’}

tagname = 'set'
tpls

Values must be of type <class ‘openpyxl.pivot.fields.TupleList’>

class openpyxl.pivot.cache.OLAPSets(count=None, set=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

set

Values must be of type <class ‘openpyxl.pivot.cache.OLAPSet’>

class openpyxl.pivot.cache.PCDKPI(uniqueName=None, caption=None, displayFolder=None, measureGroup=None, parent=None, value=None, goal=None, status=None, trend=None, weight=None, time=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

displayFolder

Values must be of type <class ‘str’>

goal

Values must be of type <class ‘str’>

measureGroup

Values must be of type <class ‘str’>

parent

Values must be of type <class ‘str’>

status

Values must be of type <class ‘str’>

tagname = 'pCDKPI'
time

Values must be of type <class ‘str’>

trend

Values must be of type <class ‘str’>

uniqueName

Values must be of type <class ‘str’>

value

Values must be of type <class ‘str’>

weight

Values must be of type <class ‘str’>

class openpyxl.pivot.cache.PCDSDTCEntries(count=None, m=None, n=None, e=None, s=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

e

Values must be of type <class ‘openpyxl.pivot.fields.Error’>

m

Values must be of type <class ‘openpyxl.pivot.fields.Missing’>

n

Values must be of type <class ‘openpyxl.pivot.fields.Number’>

s

Values must be of type <class ‘openpyxl.pivot.fields.Text’>

tagname = 'pCDSDTCEntries'
class openpyxl.pivot.cache.Page(count=None, pageItem=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
pageItem

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'PCDSCPage'
class openpyxl.pivot.cache.PageItem(name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

tagname = 'pageItem'
class openpyxl.pivot.cache.PivotDimension(measure=None, name=None, uniqueName=None, caption=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

measure

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

tagname = 'dimension'
uniqueName

Values must be of type <class ‘str’>

class openpyxl.pivot.cache.Query(mdx=None, tpls=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

mdx

Values must be of type <class ‘str’>

tagname = 'query'
tpls

Values must be of type <class ‘openpyxl.pivot.fields.TupleList’>

class openpyxl.pivot.cache.QueryCache(count=None, query=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

query

Values must be of type <class ‘openpyxl.pivot.cache.Query’>

tagname = 'queryCache'
class openpyxl.pivot.cache.RangePr(autoStart=True, autoEnd=True, groupBy='range', startNum=None, endNum=None, startDate=None, endDate=None, groupInterval=1)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoEnd

Values must be of type <class ‘bool’>

autoStart

Values must be of type <class ‘bool’>

endDate

Values must be of type <class ‘datetime.datetime’>

endNum

Values must be of type <class ‘float’>

groupBy

Value must be one of {‘years’, ‘months’, ‘seconds’, ‘days’, ‘hours’, ‘minutes’, ‘range’, ‘quarters’}

groupInterval

Values must be of type <class ‘float’>

startDate

Values must be of type <class ‘datetime.datetime’>

startNum

Values must be of type <class ‘float’>

tagname = 'rangePr'
class openpyxl.pivot.cache.RangeSet(i1=None, i2=None, i3=None, i4=None, ref=None, name=None, sheet=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

i1

Values must be of type <class ‘int’>

i2

Values must be of type <class ‘int’>

i3

Values must be of type <class ‘int’>

i4

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

ref

Values must be of type <class ‘str’>

sheet

Values must be of type <class ‘str’>

tagname = 'rangeSet'
class openpyxl.pivot.cache.ServerFormat(culture=None, format=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

culture

Values must be of type <class ‘str’>

format

Values must be of type <class ‘str’>

tagname = 'serverFormat'
class openpyxl.pivot.cache.ServerFormatList(count=None, serverFormat=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
serverFormat

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'serverFormats'
class openpyxl.pivot.cache.SharedItems(_fields=(), containsSemiMixedTypes=None, containsNonDate=None, containsDate=None, containsString=None, containsBlank=None, containsMixedTypes=None, containsNumber=None, containsInteger=None, minValue=None, maxValue=None, minDate=None, maxDate=None, count=None, longText=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

containsBlank

Values must be of type <class ‘bool’>

containsDate

Values must be of type <class ‘bool’>

containsInteger

Values must be of type <class ‘bool’>

containsMixedTypes

Values must be of type <class ‘bool’>

containsNonDate

Values must be of type <class ‘bool’>

containsNumber

Values must be of type <class ‘bool’>

containsSemiMixedTypes

Values must be of type <class ‘bool’>

containsString

Values must be of type <class ‘bool’>

count
d

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

e

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

longText

Values must be of type <class ‘bool’>

m

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

maxDate

Values must be of type <class ‘datetime.datetime’>

maxValue

Values must be of type <class ‘float’>

minDate

Values must be of type <class ‘datetime.datetime’>

minValue

Values must be of type <class ‘float’>

n

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

s

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

tagname = 'sharedItems'
class openpyxl.pivot.cache.TupleCache(entries=None, sets=None, queryCache=None, serverFormats=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

entries

Values must be of type <class ‘openpyxl.pivot.cache.PCDSDTCEntries’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

queryCache

Values must be of type <class ‘openpyxl.pivot.cache.QueryCache’>

serverFormats

Values must be of type <class ‘openpyxl.pivot.cache.ServerFormatList’>

sets

Values must be of type <class ‘openpyxl.pivot.cache.OLAPSets’>

tagname = 'tupleCache'
class openpyxl.pivot.cache.WorksheetSource(ref=None, name=None, sheet=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

ref

Values must be of type <class ‘str’>

sheet

Values must be of type <class ‘str’>

tagname = 'worksheetSource'
openpyxl.pivot.fields module
class openpyxl.pivot.fields.Boolean(x=(), v=None, u=None, f=None, c=None, cp=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

tagname = 'b'
u

Values must be of type <class ‘bool’>

v

Values must be of type <class ‘bool’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.DateTimeField(x=(), v=None, u=None, f=None, c=None, cp=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

tagname = 'd'
u

Values must be of type <class ‘bool’>

v

Values must be of type <class ‘datetime.datetime’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.Error(tpls=None, x=(), v=None, u=None, f=None, c=None, cp=None, _in=None, bc=None, fc=None, i=None, un=None, st=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘bool’>

bc
c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

fc
i

Values must be of type <class ‘bool’>

st

Values must be of type <class ‘bool’>

tagname = 'e'
tpls

Values must be of type <class ‘openpyxl.pivot.fields.TupleList’>

u

Values must be of type <class ‘bool’>

un

Values must be of type <class ‘bool’>

v

Values must be of type <class ‘str’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.Index(v=0)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'x'
v

Values must be of type <class ‘int’>

class openpyxl.pivot.fields.Missing(tpls=(), x=(), u=None, f=None, c=None, cp=None, _in=None, bc=None, fc=None, i=None, un=None, st=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘bool’>

bc
c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

fc
i

Values must be of type <class ‘bool’>

st

Values must be of type <class ‘bool’>

tagname = 'm'
tpls

A sequence (list or tuple) that may only contain objects of the declared type

u

Values must be of type <class ‘bool’>

un

Values must be of type <class ‘bool’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.Number(tpls=(), x=(), v=None, u=None, f=None, c=None, cp=None, _in=None, bc=None, fc=None, i=None, un=None, st=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘bool’>

bc
c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

fc
i

Values must be of type <class ‘bool’>

st

Values must be of type <class ‘bool’>

tagname = 'n'
tpls

A sequence (list or tuple) that may only contain objects of the declared type

u

Values must be of type <class ‘bool’>

un

Values must be of type <class ‘bool’>

v

Values must be of type <class ‘float’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.Text(tpls=(), x=(), v=None, u=None, f=None, c=None, cp=None, _in=None, bc=None, fc=None, i=None, un=None, st=None, b=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Values must be of type <class ‘bool’>

bc
c

Values must be of type <class ‘str’>

cp

Values must be of type <class ‘int’>

f

Values must be of type <class ‘bool’>

fc
i

Values must be of type <class ‘bool’>

st

Values must be of type <class ‘bool’>

tagname = 's'
tpls

A sequence (list or tuple) that may only contain objects of the declared type

u

Values must be of type <class ‘bool’>

un

Values must be of type <class ‘bool’>

v

Values must be of type <class ‘str’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.fields.Tuple(fld=None, hier=None, item=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

fld

Values must be of type <class ‘int’>

hier

Values must be of type <class ‘int’>

item

Values must be of type <class ‘int’>

class openpyxl.pivot.fields.TupleList(c=None, tpl=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

c

Values must be of type <class ‘int’>

tpl

Values must be of type <class ‘openpyxl.pivot.fields.Tuple’>

openpyxl.pivot.record module
class openpyxl.pivot.record.Record(_fields=(), m=None, n=None, b=None, e=None, s=None, d=None, x=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

b

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

d

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

e

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

m

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

n

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

s

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

tagname = 'r'
x

Allow a multisequence to be built up from parts

Excluded from the instance __elements__ or __attrs__ as is effectively an Alias

class openpyxl.pivot.record.RecordList(count=None, r=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml'
path
r

A sequence (list or tuple) that may only contain objects of the declared type

rel_type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords'
tagname = 'pivotCacheRecords'
to_tree()[source]
openpyxl.pivot.table module
class openpyxl.pivot.table.AutoSortScope(pivotArea=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

pivotArea

Values must be of type <class ‘openpyxl.pivot.table.PivotArea’>

class openpyxl.pivot.table.ChartFormat(chart=None, format=None, series=None, pivotArea=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

chart

Values must be of type <class ‘int’>

format

Values must be of type <class ‘int’>

pivotArea

Values must be of type <class ‘openpyxl.pivot.table.PivotArea’>

series

Values must be of type <class ‘bool’>

tagname = 'chartFormat'
class openpyxl.pivot.table.ColHierarchiesUsage(count=None, colHierarchyUsage=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

colHierarchyUsage

A sequence (list or tuple) that may only contain objects of the declared type

count
tagname = 'colHierarchiesUsage'
class openpyxl.pivot.table.ConditionalFormat(scope='selection', type=None, priority=None, pivotAreas=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

pivotAreas

Wrap a sequence in an containing object

priority

Values must be of type <class ‘int’>

scope

Value must be one of {‘selection’, ‘data’, ‘field’}

tagname = 'conditionalFormat'
type

Value must be one of {‘column’, ‘row’, ‘all’}

class openpyxl.pivot.table.ConditionalFormatList(conditionalFormat=(), count=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

by_priority()[source]

Return a dictionary of format objects keyed by (field id and format property). This can be used to map the formats to field but also to dedupe to match worksheet definitions which are grouped by cell range

conditionalFormat

A sequence (list or tuple) that may only contain objects of the declared type

count
tagname = 'conditionalFormats'
to_tree(tagname=None)[source]
class openpyxl.pivot.table.DataField(name=None, fld=None, subtotal='sum', showDataAs='normal', baseField=-1, baseItem=1048832, numFmtId=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

baseField

Values must be of type <class ‘int’>

baseItem

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fld

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

numFmtId

Values must be of type <class ‘int’>

showDataAs

Value must be one of {‘difference’, ‘runTotal’, ‘percentOfCol’, ‘index’, ‘percentDiff’, ‘normal’, ‘percent’, ‘percentOfRow’, ‘percentOfTotal’}

subtotal

Value must be one of {‘count’, ‘average’, ‘stdDevp’, ‘product’, ‘countNums’, ‘stdDev’, ‘min’, ‘max’, ‘sum’, ‘var’, ‘varp’}

tagname = 'dataField'
class openpyxl.pivot.table.FieldItem(n=None, t='data', h=None, s=None, sd=True, f=None, m=None, c=None, x=None, d=None, e=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

c

Values must be of type <class ‘bool’>

d

Values must be of type <class ‘bool’>

e

Values must be of type <class ‘bool’>

f

Values must be of type <class ‘bool’>

h

Values must be of type <class ‘bool’>

m

Values must be of type <class ‘bool’>

n

Values must be of type <class ‘str’>

s

Values must be of type <class ‘bool’>

sd

Values must be of type <class ‘bool’>

t

Value must be one of {‘countA’, ‘count’, ‘stdDevP’, ‘product’, ‘data’, ‘grand’, ‘sum’, ‘max’, ‘min’, ‘stdDev’, ‘blank’, ‘default’, ‘var’, ‘avg’, ‘varP’}

tagname = 'item'
x

Values must be of type <class ‘int’>

class openpyxl.pivot.table.Format(action='formatting', dxfId=None, pivotArea=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

action

Value must be one of {‘drill’, ‘formula’, ‘blank’, ‘formatting’}

dxfId

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

pivotArea

Values must be of type <class ‘openpyxl.pivot.table.PivotArea’>

tagname = 'format'
class openpyxl.pivot.table.HierarchyUsage(hierarchyUsage=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

hierarchyUsage

Values must be of type <class ‘int’>

tagname = 'hierarchyUsage'
class openpyxl.pivot.table.Location(ref=None, firstHeaderRow=None, firstDataRow=None, firstDataCol=None, rowPageCount=None, colPageCount=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

colPageCount

Values must be of type <class ‘int’>

firstDataCol

Values must be of type <class ‘int’>

firstDataRow

Values must be of type <class ‘int’>

firstHeaderRow

Values must be of type <class ‘int’>

ref

Values must be of type <class ‘str’>

rowPageCount

Values must be of type <class ‘int’>

tagname = 'location'
class openpyxl.pivot.table.MemberList(count=None, level=None, member=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
level

Values must be of type <class ‘int’>

member

Wrap a sequence in an containing object

tagname = 'members'
class openpyxl.pivot.table.MemberProperty(name=None, showCell=None, showTip=None, showAsCaption=None, nameLen=None, pPos=None, pLen=None, level=None, field=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

field

Values must be of type <class ‘int’>

level

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

nameLen

Values must be of type <class ‘int’>

pLen

Values must be of type <class ‘int’>

pPos

Values must be of type <class ‘int’>

showAsCaption

Values must be of type <class ‘bool’>

showCell

Values must be of type <class ‘bool’>

showTip

Values must be of type <class ‘bool’>

tagname = 'mps'
class openpyxl.pivot.table.PageField(fld=None, item=None, hier=None, name=None, cap=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cap

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fld

Values must be of type <class ‘int’>

hier

Values must be of type <class ‘int’>

item

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

tagname = 'pageField'
class openpyxl.pivot.table.PivotArea(references=(), extLst=None, field=None, type='normal', dataOnly=True, labelOnly=None, grandRow=None, grandCol=None, cacheIndex=None, outline=True, offset=None, collapsedLevelsAreSubtotals=None, axis=None, fieldPosition=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

axis

Value must be one of {‘axisValues’, ‘axisRow’, ‘axisCol’, ‘axisPage’}

cacheIndex

Values must be of type <class ‘bool’>

collapsedLevelsAreSubtotals

Values must be of type <class ‘bool’>

dataOnly

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

field

Values must be of type <class ‘int’>

fieldPosition

Values must be of type <class ‘int’>

grandCol

Values must be of type <class ‘bool’>

grandRow

Values must be of type <class ‘bool’>

labelOnly

Values must be of type <class ‘bool’>

offset

Values must be of type <class ‘str’>

outline

Values must be of type <class ‘bool’>

references

Wrap a sequence in an containing object

tagname = 'pivotArea'
type

Value must be one of {‘topRight’, ‘origin’, ‘data’, ‘topEnd’, ‘normal’, ‘button’, ‘all’}

class openpyxl.pivot.table.PivotField(items=(), autoSortScope=None, name=None, axis=None, dataField=None, subtotalCaption=None, showDropDowns=True, hiddenLevel=None, uniqueMemberProperty=None, compact=True, allDrilled=None, numFmtId=None, outline=True, subtotalTop=True, dragToRow=True, dragToCol=True, multipleItemSelectionAllowed=None, dragToPage=True, dragToData=True, dragOff=True, showAll=True, insertBlankRow=None, serverField=None, insertPageBreak=None, autoShow=None, topAutoShow=True, hideNewItems=None, measureFilter=None, includeNewItemsInFilter=None, itemPageCount=10, sortType='manual', dataSourceSort=None, nonAutoSortDefault=None, rankBy=None, defaultSubtotal=True, sumSubtotal=None, countASubtotal=None, avgSubtotal=None, maxSubtotal=None, minSubtotal=None, productSubtotal=None, countSubtotal=None, stdDevSubtotal=None, stdDevPSubtotal=None, varSubtotal=None, varPSubtotal=None, showPropCell=None, showPropTip=None, showPropAsCaption=None, defaultAttributeDrillState=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

allDrilled

Values must be of type <class ‘bool’>

autoShow

Values must be of type <class ‘bool’>

autoSortScope

Values must be of type <class ‘openpyxl.pivot.table.AutoSortScope’>

avgSubtotal

Values must be of type <class ‘bool’>

axis

Value must be one of {‘axisValues’, ‘axisRow’, ‘axisCol’, ‘axisPage’}

compact

Values must be of type <class ‘bool’>

countASubtotal

Values must be of type <class ‘bool’>

countSubtotal

Values must be of type <class ‘bool’>

dataField

Values must be of type <class ‘bool’>

dataSourceSort

Values must be of type <class ‘bool’>

defaultAttributeDrillState

Values must be of type <class ‘bool’>

defaultSubtotal

Values must be of type <class ‘bool’>

dragOff

Values must be of type <class ‘bool’>

dragToCol

Values must be of type <class ‘bool’>

dragToData

Values must be of type <class ‘bool’>

dragToPage

Values must be of type <class ‘bool’>

dragToRow

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

hiddenLevel

Values must be of type <class ‘bool’>

hideNewItems

Values must be of type <class ‘bool’>

includeNewItemsInFilter

Values must be of type <class ‘bool’>

insertBlankRow

Values must be of type <class ‘bool’>

insertPageBreak

Values must be of type <class ‘bool’>

itemPageCount

Values must be of type <class ‘int’>

items

Wrap a sequence in an containing object

maxSubtotal

Values must be of type <class ‘bool’>

measureFilter

Values must be of type <class ‘bool’>

minSubtotal

Values must be of type <class ‘bool’>

multipleItemSelectionAllowed

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

nonAutoSortDefault

Values must be of type <class ‘bool’>

numFmtId

Values must be of type <class ‘int’>

outline

Values must be of type <class ‘bool’>

productSubtotal

Values must be of type <class ‘bool’>

rankBy

Values must be of type <class ‘int’>

serverField

Values must be of type <class ‘bool’>

showAll

Values must be of type <class ‘bool’>

showDropDowns

Values must be of type <class ‘bool’>

showPropAsCaption

Values must be of type <class ‘bool’>

showPropCell

Values must be of type <class ‘bool’>

showPropTip

Values must be of type <class ‘bool’>

sortType

Value must be one of {‘descending’, ‘manual’, ‘ascending’}

stdDevPSubtotal

Values must be of type <class ‘bool’>

stdDevSubtotal

Values must be of type <class ‘bool’>

subtotalCaption

Values must be of type <class ‘str’>

subtotalTop

Values must be of type <class ‘bool’>

sumSubtotal

Values must be of type <class ‘bool’>

tagname = 'pivotField'
topAutoShow

Values must be of type <class ‘bool’>

uniqueMemberProperty

Values must be of type <class ‘str’>

varPSubtotal

Values must be of type <class ‘bool’>

varSubtotal

Values must be of type <class ‘bool’>

class openpyxl.pivot.table.PivotFilter(fld=None, mpFld=None, type=None, evalOrder=None, id=None, iMeasureHier=None, iMeasureFld=None, name=None, description=None, stringValue1=None, stringValue2=None, autoFilter=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoFilter

Values must be of type <class ‘openpyxl.worksheet.filters.AutoFilter’>

description

Values must be of type <class ‘str’>

evalOrder

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fld

Values must be of type <class ‘int’>

iMeasureFld

Values must be of type <class ‘int’>

iMeasureHier

Values must be of type <class ‘int’>

id

Values must be of type <class ‘int’>

mpFld

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

stringValue1

Values must be of type <class ‘str’>

stringValue2

Values must be of type <class ‘str’>

tagname = 'filter'
type

Value must be one of {‘M7’, ‘captionGreaterThanOrEqual’, ‘tomorrow’, ‘M3’, ‘Q2’, ‘dateNewerThanOrEqual’, ‘nextWeek’, ‘thisWeek’, ‘captionNotBeginsWith’, ‘dateBetween’, ‘nextMonth’, ‘yesterday’, ‘valueLessThanOrEqual’, ‘dateEqual’, ‘thisYear’, ‘nextQuarter’, ‘lastWeek’, ‘dateNotBetween’, ‘valueEqual’, ‘captionNotEqual’, ‘lastMonth’, ‘Q1’, ‘thisMonth’, ‘dateNotEqual’, ‘lastYear’, ‘yearToDate’, ‘valueNotEqual’, ‘nextYear’, ‘captionLessThan’, ‘valueLessThan’, ‘dateOlderThanOrEqual’, ‘captionEqual’, ‘unknown’, ‘M1’, ‘valueGreaterThanOrEqual’, ‘M4’, ‘captionGreaterThan’, ‘sum’, ‘dateNewerThan’, ‘M9’, ‘M11’, ‘captionBetween’, ‘captionBeginsWith’, ‘dateOlderThan’, ‘Q3’, ‘M12’, ‘thisQuarter’, ‘lastQuarter’, ‘count’, ‘M5’, ‘M10’, ‘captionNotBetween’, ‘captionNotContains’, ‘Q4’, ‘captionEndsWith’, ‘captionNotEndsWith’, ‘M2’, ‘M6’, ‘today’, ‘valueNotBetween’, ‘M8’, ‘captionLessThanOrEqual’, ‘valueGreaterThan’, ‘valueBetween’, ‘percent’, ‘captionContains’}

class openpyxl.pivot.table.PivotFilters(count=None, filter=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

filter

Values must be of type <class ‘openpyxl.pivot.table.PivotFilter’>

class openpyxl.pivot.table.PivotHierarchy(outline=None, multipleItemSelectionAllowed=None, subtotalTop=None, showInFieldList=None, dragToRow=None, dragToCol=None, dragToPage=None, dragToData=None, dragOff=None, includeNewItemsInFilter=None, caption=None, mps=(), members=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caption

Values must be of type <class ‘str’>

dragOff

Values must be of type <class ‘bool’>

dragToCol

Values must be of type <class ‘bool’>

dragToData

Values must be of type <class ‘bool’>

dragToPage

Values must be of type <class ‘bool’>

dragToRow

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

includeNewItemsInFilter

Values must be of type <class ‘bool’>

members

Values must be of type <class ‘openpyxl.pivot.table.MemberList’>

mps

Wrap a sequence in an containing object

multipleItemSelectionAllowed

Values must be of type <class ‘bool’>

outline

Values must be of type <class ‘bool’>

showInFieldList

Values must be of type <class ‘bool’>

subtotalTop

Values must be of type <class ‘bool’>

tagname = 'pivotHierarchy'
class openpyxl.pivot.table.PivotTableStyle(name=None, showRowHeaders=None, showColHeaders=None, showRowStripes=None, showColStripes=None, showLastColumn=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

showColHeaders

Values must be of type <class ‘bool’>

showColStripes

Values must be of type <class ‘bool’>

showLastColumn

Values must be of type <class ‘bool’>

showRowHeaders

Values must be of type <class ‘bool’>

showRowStripes

Values must be of type <class ‘bool’>

tagname = 'pivotTableStyleInfo'
class openpyxl.pivot.table.Reference(field=None, count=None, selected=None, byPosition=None, relative=None, defaultSubtotal=None, sumSubtotal=None, countASubtotal=None, avgSubtotal=None, maxSubtotal=None, minSubtotal=None, productSubtotal=None, countSubtotal=None, stdDevSubtotal=None, stdDevPSubtotal=None, varSubtotal=None, varPSubtotal=None, x=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

avgSubtotal

Values must be of type <class ‘bool’>

byPosition

Values must be of type <class ‘bool’>

count
countASubtotal

Values must be of type <class ‘bool’>

countSubtotal

Values must be of type <class ‘bool’>

defaultSubtotal

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

field

Values must be of type <class ‘int’>

maxSubtotal

Values must be of type <class ‘bool’>

minSubtotal

Values must be of type <class ‘bool’>

productSubtotal

Values must be of type <class ‘bool’>

relative

Values must be of type <class ‘bool’>

selected

Values must be of type <class ‘bool’>

stdDevPSubtotal

Values must be of type <class ‘bool’>

stdDevSubtotal

Values must be of type <class ‘bool’>

sumSubtotal

Values must be of type <class ‘bool’>

tagname = 'reference'
varPSubtotal

Values must be of type <class ‘bool’>

varSubtotal

Values must be of type <class ‘bool’>

x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.table.RowColField(x=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'field'
x

Values must be of type <class ‘int’>

class openpyxl.pivot.table.RowColItem(t='data', r=0, i=0, x=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

i

Values must be of type <class ‘int’>

r

Values must be of type <class ‘int’>

t

Value must be one of {‘countA’, ‘count’, ‘stdDevP’, ‘product’, ‘data’, ‘grand’, ‘sum’, ‘max’, ‘min’, ‘stdDev’, ‘blank’, ‘default’, ‘var’, ‘avg’, ‘varP’}

tagname = 'i'
x

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.pivot.table.RowHierarchiesUsage(count=None, rowHierarchyUsage=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
rowHierarchyUsage

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'rowHierarchiesUsage'
class openpyxl.pivot.table.TableDefinition(name=None, cacheId=None, dataOnRows=False, dataPosition=None, dataCaption=None, grandTotalCaption=None, errorCaption=None, showError=False, missingCaption=None, showMissing=True, pageStyle=None, pivotTableStyle=None, vacatedStyle=None, tag=None, updatedVersion=0, minRefreshableVersion=0, asteriskTotals=False, showItems=True, editData=False, disableFieldList=False, showCalcMbrs=True, visualTotals=True, showMultipleLabel=True, showDataDropDown=True, showDrill=True, printDrill=False, showMemberPropertyTips=True, showDataTips=True, enableWizard=True, enableDrill=True, enableFieldProperties=True, preserveFormatting=True, useAutoFormatting=False, pageWrap=0, pageOverThenDown=False, subtotalHiddenItems=False, rowGrandTotals=True, colGrandTotals=True, fieldPrintTitles=False, itemPrintTitles=False, mergeItem=False, showDropZones=True, createdVersion=0, indent=1, showEmptyRow=False, showEmptyCol=False, showHeaders=True, compact=True, outline=False, outlineData=False, compactData=True, published=False, gridDropZones=False, immersive=True, multipleFieldFilters=None, chartFormat=0, rowHeaderCaption=None, colHeaderCaption=None, fieldListSortAscending=None, mdxSubqueries=None, customListSort=None, autoFormatId=None, applyNumberFormats=False, applyBorderFormats=False, applyFontFormats=False, applyPatternFormats=False, applyAlignmentFormats=False, applyWidthHeightFormats=False, location=None, pivotFields=(), rowFields=(), rowItems=(), colFields=(), colItems=(), pageFields=(), dataFields=(), formats=(), conditionalFormats=None, chartFormats=(), pivotHierarchies=(), pivotTableStyleInfo=None, filters=(), rowHierarchiesUsage=None, colHierarchiesUsage=None, extLst=None, id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

applyAlignmentFormats

Values must be of type <class ‘bool’>

applyBorderFormats

Values must be of type <class ‘bool’>

applyFontFormats

Values must be of type <class ‘bool’>

applyNumberFormats

Values must be of type <class ‘bool’>

applyPatternFormats

Values must be of type <class ‘bool’>

applyWidthHeightFormats

Values must be of type <class ‘bool’>

asteriskTotals

Values must be of type <class ‘bool’>

autoFormatId

Values must be of type <class ‘int’>

cache = None
cacheId

Values must be of type <class ‘int’>

chartFormat

Values must be of type <class ‘int’>

chartFormats

Wrap a sequence in an containing object

colFields

Wrap a sequence in an containing object

colGrandTotals

Values must be of type <class ‘bool’>

colHeaderCaption

Values must be of type <class ‘str’>

colHierarchiesUsage

Values must be of type <class ‘openpyxl.pivot.table.ColHierarchiesUsage’>

colItems

Wrap a sequence in an containing object

compact

Values must be of type <class ‘bool’>

compactData

Values must be of type <class ‘bool’>

conditionalFormats

Values must be of type <class ‘openpyxl.pivot.table.ConditionalFormatList’>

createdVersion

Values must be of type <class ‘int’>

customListSort

Values must be of type <class ‘bool’>

dataCaption

Values must be of type <class ‘str’>

dataFields

Wrap a sequence in an containing object

dataOnRows

Values must be of type <class ‘bool’>

dataPosition

Values must be of type <class ‘int’>

disableFieldList

Values must be of type <class ‘bool’>

editData

Values must be of type <class ‘bool’>

enableDrill

Values must be of type <class ‘bool’>

enableFieldProperties

Values must be of type <class ‘bool’>

enableWizard

Values must be of type <class ‘bool’>

errorCaption

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fieldListSortAscending

Values must be of type <class ‘bool’>

fieldPrintTitles

Values must be of type <class ‘bool’>

filters

Wrap a sequence in an containing object

formats

Wrap a sequence in an containing object

formatted_fields()[source]

Map fields to associated conditional formats by priority

grandTotalCaption

Values must be of type <class ‘str’>

gridDropZones

Values must be of type <class ‘bool’>

id

Values must be of type <class ‘str’>

immersive

Values must be of type <class ‘bool’>

indent

Values must be of type <class ‘int’>

itemPrintTitles

Values must be of type <class ‘bool’>

location

Values must be of type <class ‘openpyxl.pivot.table.Location’>

mdxSubqueries

Values must be of type <class ‘bool’>

mergeItem

Values must be of type <class ‘bool’>

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml'
minRefreshableVersion

Values must be of type <class ‘int’>

missingCaption

Values must be of type <class ‘str’>

multipleFieldFilters

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

outline

Values must be of type <class ‘bool’>

outlineData

Values must be of type <class ‘bool’>

pageFields

Wrap a sequence in an containing object

pageOverThenDown

Values must be of type <class ‘bool’>

pageStyle

Values must be of type <class ‘str’>

pageWrap

Values must be of type <class ‘int’>

path
pivotFields

Wrap a sequence in an containing object

pivotHierarchies

Wrap a sequence in an containing object

pivotTableStyle

Values must be of type <class ‘str’>

pivotTableStyleInfo

Values must be of type <class ‘openpyxl.pivot.table.PivotTableStyle’>

preserveFormatting

Values must be of type <class ‘bool’>

printDrill

Values must be of type <class ‘bool’>

published

Values must be of type <class ‘bool’>

rel_type = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable'
rowFields

Wrap a sequence in an containing object

rowGrandTotals

Values must be of type <class ‘bool’>

rowHeaderCaption

Values must be of type <class ‘str’>

rowHierarchiesUsage

Values must be of type <class ‘openpyxl.pivot.table.RowHierarchiesUsage’>

rowItems

Wrap a sequence in an containing object

showCalcMbrs

Values must be of type <class ‘bool’>

showDataDropDown

Values must be of type <class ‘bool’>

showDataTips

Values must be of type <class ‘bool’>

showDrill

Values must be of type <class ‘bool’>

showDropZones

Values must be of type <class ‘bool’>

showEmptyCol

Values must be of type <class ‘bool’>

showEmptyRow

Values must be of type <class ‘bool’>

showError

Values must be of type <class ‘bool’>

showHeaders

Values must be of type <class ‘bool’>

showItems

Values must be of type <class ‘bool’>

showMemberPropertyTips

Values must be of type <class ‘bool’>

showMissing

Values must be of type <class ‘bool’>

showMultipleLabel

Values must be of type <class ‘bool’>

subtotalHiddenItems

Values must be of type <class ‘bool’>

summary

Provide a simplified summary of the table

tag

Values must be of type <class ‘str’>

tagname = 'pivotTableDefinition'
to_tree()[source]
updatedVersion

Values must be of type <class ‘int’>

useAutoFormatting

Values must be of type <class ‘bool’>

vacatedStyle

Values must be of type <class ‘str’>

visualTotals

Values must be of type <class ‘bool’>

openpyxl.reader package
Submodules
openpyxl.reader.drawings module
openpyxl.reader.drawings.find_images(archive, path)[source]

Given the path to a drawing file extract charts and images

Ignore errors due to unsupported parts of DrawingML

openpyxl.reader.excel module

Read an xlsx file into Python

class openpyxl.reader.excel.ExcelReader(fn, read_only=False, keep_vba=False, data_only=False, keep_links=True, rich_text=False)[source]

Bases: object

Read an Excel package and dispatch the contents to the relevant modules

read()[source]
read_chartsheet(sheet, rel)[source]
read_custom()[source]
read_manifest()[source]
read_properties()[source]
read_strings()[source]
read_theme()[source]
read_workbook()[source]
read_worksheets()[source]
openpyxl.reader.excel.load_workbook(filename, read_only=False, keep_vba=False, data_only=False, keep_links=True, rich_text=False)[source]

Open the given filename and return the workbook

Parameters:
  • filename (string or a file-like object open in binary mode c.f., zipfile.ZipFile) – the path to open or a file-like object
  • read_only (bool) – optimised for reading, content cannot be edited
  • keep_vba (bool) – preserve vba content (this does NOT mean you can use it)
  • data_only (bool) – controls whether cells with formulae have either the formula (default) or the value stored the last time Excel read the sheet
  • keep_links (bool) – whether links to external workbooks should be preserved. The default is True
  • rich_text (bool) – if set to True openpyxl will preserve any rich text formatting in cells. The default is False
Return type:

openpyxl.workbook.Workbook

Note

When using lazy load, all worksheets will be openpyxl.worksheet.iter_worksheet.IterableWorksheet and the returned workbook will be read-only.

openpyxl.reader.strings module
openpyxl.reader.strings.read_rich_text(xml_source)[source]

Read in all shared strings in the table

openpyxl.reader.strings.read_string_table(xml_source)[source]

Read in all shared strings in the table

openpyxl.reader.workbook module
class openpyxl.reader.workbook.WorkbookParser(archive, workbook_part_name, keep_links=True)[source]

Bases: object

assign_names()[source]

Bind defined names and other definitions to worksheets or the workbook

find_sheets()[source]

Find all sheets in the workbook and return the link to the source file.

Older XLSM files sometimes contain invalid sheet elements. Warn user when these are removed.

parse()[source]
pivot_caches

Get PivotCache objects

rels
openpyxl.styles package
Submodules
openpyxl.styles.alignment module
class openpyxl.styles.alignment.Alignment(horizontal=None, vertical=None, textRotation=0, wrapText=None, shrinkToFit=None, indent=0, relativeIndent=0, justifyLastLine=None, readingOrder=0, text_rotation=None, wrap_text=None, shrink_to_fit=None, mergeCell=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Alignment options for use in styles.

horizontal

Value must be one of {‘right’, ‘general’, ‘justify’, ‘fill’, ‘left’, ‘center’, ‘centerContinuous’, ‘distributed’}

indent

Values must be of type <class ‘float’>

justifyLastLine

Values must be of type <class ‘bool’>

readingOrder

Values must be of type <class ‘float’>

relativeIndent

Values must be of type <class ‘float’>

shrinkToFit

Values must be of type <class ‘bool’>

shrink_to_fit

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'alignment'
textRotation

Value must be one of {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180}

text_rotation

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

vertical

Value must be one of {‘distributed’, ‘justify’, ‘center’, ‘bottom’, ‘top’}

wrapText

Values must be of type <class ‘bool’>

wrap_text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

openpyxl.styles.borders module
class openpyxl.styles.borders.Border(left=None, right=None, top=None, bottom=None, diagonal=None, diagonal_direction=None, vertical=None, horizontal=None, diagonalUp=False, diagonalDown=False, outline=True, start=None, end=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Border positioning for use in styles.

bottom

Values must be of type <class ‘openpyxl.styles.borders.Side’>

diagonal

Values must be of type <class ‘openpyxl.styles.borders.Side’>

diagonalDown

Values must be of type <class ‘bool’>

diagonalUp

Values must be of type <class ‘bool’>

end

Values must be of type <class ‘openpyxl.styles.borders.Side’>

horizontal

Values must be of type <class ‘openpyxl.styles.borders.Side’>

left

Values must be of type <class ‘openpyxl.styles.borders.Side’>

outline

Values must be of type <class ‘bool’>

right

Values must be of type <class ‘openpyxl.styles.borders.Side’>

start

Values must be of type <class ‘openpyxl.styles.borders.Side’>

tagname = 'border'
top

Values must be of type <class ‘openpyxl.styles.borders.Side’>

vertical

Values must be of type <class ‘openpyxl.styles.borders.Side’>

class openpyxl.styles.borders.Side(style=None, color=None, border_style=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Border options for use in styles. Caution: if you do not specify a border_style, other attributes will have no effect !

border_style

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

color

Values must be of type <class ‘openpyxl.styles.colors.Color’>

style

Value must be one of {‘hair’, ‘dotted’, ‘mediumDashDotDot’, ‘thin’, ‘dashDotDot’, ‘double’, ‘mediumDashDot’, ‘slantDashDot’, ‘dashDot’, ‘mediumDashed’, ‘medium’, ‘thick’, ‘dashed’}

openpyxl.styles.builtins module
openpyxl.styles.cell_style module
class openpyxl.styles.cell_style.ArrayDescriptor(key)[source]

Bases: object

class openpyxl.styles.cell_style.CellStyle(numFmtId=0, fontId=0, fillId=0, borderId=0, xfId=None, quotePrefix=None, pivotButton=None, applyNumberFormat=None, applyFont=None, applyFill=None, applyBorder=None, applyAlignment=None, applyProtection=None, alignment=None, protection=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alignment

Values must be of type <class ‘openpyxl.styles.alignment.Alignment’>

applyAlignment
applyBorder

Values must be of type <class ‘bool’>

applyFill

Values must be of type <class ‘bool’>

applyFont

Values must be of type <class ‘bool’>

applyNumberFormat

Values must be of type <class ‘bool’>

applyProtection
borderId

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fillId

Values must be of type <class ‘int’>

fontId

Values must be of type <class ‘int’>

classmethod from_array(style)[source]

Convert from StyleArray

numFmtId

Values must be of type <class ‘int’>

pivotButton

Values must be of type <class ‘bool’>

protection

Values must be of type <class ‘openpyxl.styles.protection.Protection’>

quotePrefix

Values must be of type <class ‘bool’>

tagname = 'xf'
to_array()[source]

Convert to StyleArray

xfId

Values must be of type <class ‘int’>

class openpyxl.styles.cell_style.CellStyleList(count=None, xf=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alignment

A sequence (list or tuple) that may only contain objects of the declared type

count
protection

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'cellXfs'
xf

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.styles.cell_style.StyleArray[source]

Bases: array.array

Simplified named tuple with an array

alignmentId
borderId
fillId
fontId
numFmtId
pivotButton
protectionId
quotePrefix
tagname = 'xf'
xfId
openpyxl.styles.colors module
class openpyxl.styles.colors.Color(rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, index=None, type='rgb')[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Named colors for use in styles.

auto

Values must be of type <class ‘bool’>

index
indexed

Values must be of type <class ‘int’>

rgb

Values must be of type <class ‘str’>

tagname = 'color'
theme

Values must be of type <class ‘int’>

tint

Values must be of type <class ‘float’>

type

Values must be of type <class ‘str’>

value
class openpyxl.styles.colors.ColorDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

expected_type

alias of Color

class openpyxl.styles.colors.ColorList(indexedColors=(), mruColors=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

index
indexedColors

Wrap a sequence in an containing object

mruColors

Wrap a sequence in an containing object

tagname = 'colors'
class openpyxl.styles.colors.RGB(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Typed

Descriptor for aRGB values If not supplied alpha is 00

expected_type

alias of builtins.str

class openpyxl.styles.colors.RgbColor(rgb=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

rgb

Values must be of type <class ‘str’>

tagname = 'rgbColor'
openpyxl.styles.differential module
class openpyxl.styles.differential.DifferentialStyle(font=None, numFmt=None, fill=None, alignment=None, border=None, protection=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

alignment

Values must be of type <class ‘openpyxl.styles.alignment.Alignment’>

border

Values must be of type <class ‘openpyxl.styles.borders.Border’>

fill

Values must be of type <class ‘openpyxl.styles.fills.Fill’>

font

Values must be of type <class ‘openpyxl.styles.fonts.Font’>

numFmt

Values must be of type <class ‘openpyxl.styles.numbers.NumberFormat’>

protection

Values must be of type <class ‘openpyxl.styles.protection.Protection’>

tagname = 'dxf'
class openpyxl.styles.differential.DifferentialStyleList(dxf=(), count=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Dedupable container for differential styles.

add(dxf)[source]

Add a differential style and return its index

append(dxf)[source]

Check to see whether style already exists and append it if does not.

count
dxf

A sequence (list or tuple) that may only contain objects of the declared type

styles

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'dxfs'
openpyxl.styles.fills module
class openpyxl.styles.fills.Fill[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Base class

classmethod from_tree(el)[source]

Create object from XML

tagname = 'fill'
class openpyxl.styles.fills.GradientFill(type='linear', degree=0, left=0, right=0, top=0, bottom=0, stop=())[source]

Bases: openpyxl.styles.fills.Fill

Fill areas with gradient

Two types of gradient fill are supported:

  • A type=’linear’ gradient interpolates colours between a set of specified Stops, across the length of an area. The gradient is left-to-right by default, but this orientation can be modified with the degree attribute. A list of Colors can be provided instead and they will be positioned with equal distance between them.
  • A type=’path’ gradient applies a linear gradient from each edge of the area. Attributes top, right, bottom, left specify the extent of fill from the respective borders. Thus top=”0.2” will fill the top 20% of the cell.
bottom

Values must be of type <class ‘float’>

degree

Values must be of type <class ‘float’>

fill_type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

left

Values must be of type <class ‘float’>

right

Values must be of type <class ‘float’>

stop
tagname = 'gradientFill'
to_tree(tagname=None, namespace=None, idx=None)[source]
top

Values must be of type <class ‘float’>

type

Value must be one of {‘path’, ‘linear’}

class openpyxl.styles.fills.PatternFill(patternType=None, fgColor=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', bgColor=<openpyxl.styles.colors.Color object> Parameters: rgb='00000000', indexed=None, auto=None, theme=None, tint=0.0, type='rgb', fill_type=None, start_color=None, end_color=None)[source]

Bases: openpyxl.styles.fills.Fill

Area fill patterns for use in styles. Caution: if you do not specify a fill_type, other attributes will have no effect !

bgColor

Values must be of type <class ‘openpyxl.styles.colors.Color’>

end_color

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

fgColor

Values must be of type <class ‘openpyxl.styles.colors.Color’>

fill_type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

patternType

Value must be one of {‘lightGray’, ‘gray125’, ‘lightVertical’, ‘mediumGray’, ‘darkGrid’, ‘darkHorizontal’, ‘darkGray’, ‘darkVertical’, ‘lightHorizontal’, ‘solid’, ‘gray0625’, ‘lightTrellis’, ‘lightUp’, ‘darkDown’, ‘darkUp’, ‘lightGrid’, ‘lightDown’, ‘darkTrellis’}

start_color

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

tagname = 'patternFill'
to_tree(tagname=None, idx=None)[source]
class openpyxl.styles.fills.Stop(color, position)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

color

Values must be of type <class ‘openpyxl.styles.colors.Color’>

position

Values must be of type <class ‘float’>

tagname = 'stop'
class openpyxl.styles.fills.StopList(name=None, **kw)[source]

Bases: openpyxl.descriptors.sequence.Sequence

expected_type

alias of Stop

openpyxl.styles.fonts module
class openpyxl.styles.fonts.Font(name=None, sz=None, b=None, i=None, charset=None, u=None, strike=None, color=None, scheme=None, family=None, size=None, bold=None, italic=None, strikethrough=None, underline=None, vertAlign=None, outline=None, shadow=None, condense=None, extend=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Font options used in styles.

UNDERLINE_DOUBLE = 'double'
UNDERLINE_DOUBLE_ACCOUNTING = 'doubleAccounting'
UNDERLINE_SINGLE = 'single'
UNDERLINE_SINGLE_ACCOUNTING = 'singleAccounting'
b

Values must be of type <class ‘bool’>

bold

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

charset

Values must be of type <class ‘int’>

color

Values must be of type <class ‘openpyxl.styles.colors.Color’>

condense

Values must be of type <class ‘bool’>

extend

Values must be of type <class ‘bool’>

family

Values must be of type <class ‘float’>

classmethod from_tree(node)[source]

Set default value for underline if child element is present

i

Values must be of type <class ‘bool’>

italic

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

name

Values must be of type <class ‘str’>

outline

Values must be of type <class ‘bool’>

scheme

Value must be one of {‘major’, ‘minor’}

shadow

Values must be of type <class ‘bool’>

size

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

strike

Values must be of type <class ‘bool’>

strikethrough

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

sz

Values must be of type <class ‘float’>

tagname = 'font'
u

Value must be one of {‘single’, ‘singleAccounting’, ‘double’, ‘doubleAccounting’}

underline

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

vertAlign

Value must be one of {‘superscript’, ‘baseline’, ‘subscript’}

openpyxl.styles.named_styles module
class openpyxl.styles.named_styles.NamedStyle(name='Normal', font=None, fill=None, border=None, alignment=None, number_format=None, protection=None, builtinId=None, hidden=False, xfId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Named and editable styles

alignment

Values must be of type <class ‘openpyxl.styles.alignment.Alignment’>

as_name()[source]

Return relevant named style

as_tuple()[source]

Return a style array representing the current style

as_xf()[source]

Return equivalent XfStyle

bind(wb)[source]

Bind a named style to a workbook

border

Values must be of type <class ‘openpyxl.styles.borders.Border’>

builtinId

Values must be of type <class ‘int’>

fill

Values must be of type <class ‘openpyxl.styles.fills.Fill’>

font

Values must be of type <class ‘openpyxl.styles.fonts.Font’>

hidden

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

number_format

Values must be of type <class ‘str’>

protection

Values must be of type <class ‘openpyxl.styles.protection.Protection’>

xfId

Index of the style in the list of named styles

class openpyxl.styles.named_styles.NamedStyleList[source]

Bases: list

Named styles are editable and can be applied to multiple objects

As only the index is stored in referencing objects the order mus be preserved.

append(style)[source]

Append object to the end of the list.

names
openpyxl.styles.numbers module
class openpyxl.styles.numbers.NumberFormat(numFmtId=None, formatCode=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

formatCode

Values must be of type <class ‘str’>

numFmtId

Values must be of type <class ‘int’>

class openpyxl.styles.numbers.NumberFormatDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.String

class openpyxl.styles.numbers.NumberFormatList(count=None, numFmt=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
numFmt

A sequence (list or tuple) that may only contain objects of the declared type

openpyxl.styles.numbers.builtin_format_code(index)[source]

Return one of the standard format codes by index.

openpyxl.styles.numbers.builtin_format_id(fmt)[source]

Return the id of a standard style.

openpyxl.styles.numbers.is_builtin(fmt)[source]
openpyxl.styles.numbers.is_date_format(fmt)[source]
openpyxl.styles.numbers.is_datetime(fmt)[source]

Return date, time or datetime

openpyxl.styles.numbers.is_timedelta_format(fmt)[source]
openpyxl.styles.protection module
class openpyxl.styles.protection.Protection(locked=True, hidden=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Protection options for use in styles.

hidden

Values must be of type <class ‘bool’>

locked

Values must be of type <class ‘bool’>

tagname = 'protection'
openpyxl.styles.proxy module
class openpyxl.styles.proxy.StyleProxy(target)[source]

Bases: object

Proxy formatting objects so that they cannot be altered

copy(**kw)[source]

Return a copy of the proxied object. Keyword args will be passed through

Note

Deprecated: Use copy(obj) or cell.obj = cell.obj + other

openpyxl.styles.styleable module
class openpyxl.styles.styleable.NamedStyleDescriptor[source]

Bases: object

collection = '_named_styles'
key = 'xfId'
class openpyxl.styles.styleable.NumberFormatDescriptor[source]

Bases: object

collection = '_number_formats'
key = 'numFmtId'
class openpyxl.styles.styleable.StyleArrayDescriptor(key)[source]

Bases: object

class openpyxl.styles.styleable.StyleDescriptor(collection, key)[source]

Bases: object

class openpyxl.styles.styleable.StyleableObject(sheet, style_array=None)[source]

Bases: object

Base class for styleble objects implementing proxy and lookup functions

alignment
border
fill
font
has_style
number_format
parent
pivotButton
protection
quotePrefix
style
style_id
openpyxl.styles.stylesheet module
class openpyxl.styles.stylesheet.Stylesheet(numFmts=None, fonts=(), fills=(), borders=(), cellStyleXfs=None, cellXfs=None, cellStyles=None, dxfs=(), tableStyles=None, colors=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

borders

Wrap a sequence in an containing object

cellStyleXfs

Values must be of type <class ‘openpyxl.styles.cell_style.CellStyleList’>

cellStyles

Values must be of type <class ‘openpyxl.styles.named_styles._NamedCellStyleList’>

cellXfs

Values must be of type <class ‘openpyxl.styles.cell_style.CellStyleList’>

colors

Values must be of type <class ‘openpyxl.styles.colors.ColorList’>

custom_formats
dxfs

Wrap a sequence in an containing object

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

fills

Wrap a sequence in an containing object

fonts

Wrap a sequence in an containing object

classmethod from_tree(node)[source]

Create object from XML

numFmts

Values must be of type <class ‘openpyxl.styles.numbers.NumberFormatList’>

tableStyles

Values must be of type <class ‘openpyxl.styles.table.TableStyleList’>

tagname = 'styleSheet'
to_tree(tagname=None, idx=None, namespace=None)[source]
openpyxl.styles.stylesheet.apply_stylesheet(archive, wb)[source]

Add styles to workbook if present

openpyxl.styles.stylesheet.write_stylesheet(wb)[source]
openpyxl.styles.table module
class openpyxl.styles.table.TableStyle(name=None, pivot=None, table=None, count=None, tableStyleElement=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

pivot

Values must be of type <class ‘bool’>

table

Values must be of type <class ‘bool’>

tableStyleElement

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'tableStyle'
class openpyxl.styles.table.TableStyleElement(type=None, size=None, dxfId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dxfId

Values must be of type <class ‘int’>

size

Values must be of type <class ‘int’>

tagname = 'tableStyleElement'
type

Value must be one of {‘pageFieldLabels’, ‘wholeTable’, ‘firstTotalCell’, ‘secondSubtotalColumn’, ‘totalRow’, ‘thirdColumnSubheading’, ‘secondColumnStripe’, ‘blankRow’, ‘headerRow’, ‘firstColumnStripe’, ‘lastColumn’, ‘lastHeaderCell’, ‘thirdSubtotalColumn’, ‘lastTotalCell’, ‘secondSubtotalRow’, ‘firstColumnSubheading’, ‘firstRowStripe’, ‘secondRowSubheading’, ‘thirdRowSubheading’, ‘firstHeaderCell’, ‘thirdSubtotalRow’, ‘firstColumn’, ‘firstSubtotalColumn’, ‘secondRowStripe’, ‘firstRowSubheading’, ‘firstSubtotalRow’, ‘pageFieldValues’, ‘secondColumnSubheading’}

class openpyxl.styles.table.TableStyleList(count=None, defaultTableStyle='TableStyleMedium9', defaultPivotStyle='PivotStyleLight16', tableStyle=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
defaultPivotStyle

Values must be of type <class ‘str’>

defaultTableStyle

Values must be of type <class ‘str’>

tableStyle

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'tableStyles'
openpyxl.utils package
Submodules
openpyxl.utils.bound_dictionary module
class openpyxl.utils.bound_dictionary.BoundDictionary(reference=None, *args, **kw)[source]

Bases: collections.defaultdict

A default dictionary where elements are tightly coupled.

The factory method is responsible for binding the parent object to the child.

If a reference attribute is assigned then child objects will have the key assigned to this.

Otherwise it’s just a defaultdict.

openpyxl.utils.cell module

Collection of utilities used within the package and also available for client code

openpyxl.utils.cell.absolute_coordinate(coord_string)[source]

Convert a coordinate to an absolute coordinate string (B12 -> $B$12)

openpyxl.utils.cell.cols_from_range(range_string)[source]

Get individual addresses for every cell in a range. Yields one row at a time.

openpyxl.utils.cell.column_index_from_string(str_col)[source]

Convert a column name into a numerical index (‘A’ -> 1)

openpyxl.utils.cell.coordinate_from_string(coord_string)[source]

Convert a coordinate string like ‘B12’ to a tuple (‘B’, 12)

openpyxl.utils.cell.coordinate_to_tuple(coordinate)[source]

Convert an Excel style coordinate to (row, column) tuple

openpyxl.utils.cell.get_column_interval(start, end)[source]

Given the start and end columns, return all the columns in the series.

The start and end columns can be either column letters or 1-based indexes.

openpyxl.utils.cell.get_column_letter(idx)[source]

Convert a column index into a column letter (3 -> ‘C’)

openpyxl.utils.cell.quote_sheetname(sheetname)[source]

Add quotes around sheetnames if they contain spaces.

openpyxl.utils.cell.range_boundaries(range_string)[source]

Convert a range string into a tuple of boundaries: (min_col, min_row, max_col, max_row) Cell coordinates will be converted into a range with the cell at both end

openpyxl.utils.cell.range_to_tuple(range_string)[source]

Convert a worksheet range to the sheetname and maximum and minimum coordinate indices

openpyxl.utils.cell.rows_from_range(range_string)[source]

Get individual addresses for every cell in a range. Yields one row at a time.

openpyxl.utils.dataframe module
openpyxl.utils.dataframe.dataframe_to_rows(df, index=True, header=True)[source]

Convert a Pandas dataframe into something suitable for passing into a worksheet. If index is True then the index will be included, starting one row below the header. If header is True then column headers will be included starting one column to the right. Formatting should be done by client code.

openpyxl.utils.dataframe.expand_index(index, header=False)[source]

Expand axis or column Multiindex For columns use header = True For axes use header = False (default)

openpyxl.utils.datetime module

Manage Excel date weirdness.

openpyxl.utils.datetime.days_to_time(value)[source]
openpyxl.utils.datetime.from_ISO8601(formatted_string)[source]

Convert from a timestamp string to a datetime object. According to 18.17.4 in the specification the following ISO 8601 formats are supported.

Dates B.1.1 and B.2.1 Times B.1.2 and B.2.2 Datetimes B.1.3 and B.2.3

There is no concept of timedeltas in the specification, but Excel writes them (in strict OOXML mode), so these are also understood.

openpyxl.utils.datetime.from_excel(value, epoch=datetime.datetime(1899, 12, 30, 0, 0), timedelta=False)[source]

Convert Excel serial to Python datetime

openpyxl.utils.datetime.time_to_days(value)[source]

Convert a time value to fractions of day

openpyxl.utils.datetime.timedelta_to_days(value)[source]

Convert a timedelta value to fractions of a day

openpyxl.utils.datetime.to_ISO8601(dt)[source]

Convert from a datetime to a timestamp string.

openpyxl.utils.datetime.to_excel(dt, epoch=datetime.datetime(1899, 12, 30, 0, 0))[source]

Convert Python datetime to Excel serial

openpyxl.utils.escape module

OOXML has non-standard escaping for characters < 

openpyxl.utils.escape.escape(value)[source]

Convert ASCII < 31 to OOXML: n == _x + hex(ord(n)) + _

openpyxl.utils.escape.unescape(value)[source]

Convert escaped strings to ASCIII: _x000a_ == n

openpyxl.utils.exceptions module

Definitions for openpyxl shared exception classes.

exception openpyxl.utils.exceptions.CellCoordinatesException[source]

Bases: Exception

Error for converting between numeric and A1-style cell references.

exception openpyxl.utils.exceptions.IllegalCharacterError[source]

Bases: Exception

The data submitted which cannot be used directly in Excel files. It must be removed or escaped.

exception openpyxl.utils.exceptions.InvalidFileException[source]

Bases: Exception

Error for trying to open a non-ooxml file.

exception openpyxl.utils.exceptions.NamedRangeException[source]

Bases: Exception

Error for badly formatted named ranges.

exception openpyxl.utils.exceptions.ReadOnlyWorkbookException[source]

Bases: Exception

Error for trying to modify a read-only workbook

exception openpyxl.utils.exceptions.SheetTitleException[source]

Bases: Exception

Error for bad sheet names.

exception openpyxl.utils.exceptions.WorkbookAlreadySaved[source]

Bases: Exception

Error when attempting to perform operations on a dump workbook while it has already been dumped once

openpyxl.utils.indexed_list module
class openpyxl.utils.indexed_list.IndexedList(iterable=None)[source]

Bases: list

List with optimised access by value Based on Alex Martelli’s recipe

http://code.activestate.com/recipes/52303-the-auxiliary-dictionary-idiom-for-sequences-with-/

add(value)[source]
append(value)[source]

Append object to the end of the list.

index(value)[source]

Return first index of value.

Raises ValueError if the value is not present.

openpyxl.utils.inference module

Type inference functions

openpyxl.utils.inference.cast_numeric(value)[source]

Explicitly convert a string to a numeric value

openpyxl.utils.inference.cast_percentage(value)[source]

Explicitly convert a string to numeric value and format as a percentage

openpyxl.utils.inference.cast_time(value)[source]

Explicitly convert a string to a number and format as datetime or time

openpyxl.utils.protection module
openpyxl.utils.protection.hash_password(plaintext_password='')[source]

Create a password hash from a given string for protecting a worksheet only. This will not work for encrypting a workbook.

This method is based on the algorithm provided by Daniel Rentz of OpenOffice and the PEAR package Spreadsheet_Excel_Writer by Xavier Noguer <xnoguer@rezebra.com>. See also http://blogs.msdn.com/b/ericwhite/archive/2008/02/23/the-legacy-hashing-algorithm-in-open-xml.aspx

openpyxl.utils.units module
openpyxl.utils.units.DEFAULT_HEADER = 0.3

From the ECMA Spec (4th Edition part 1) Page setup: “Left Page Margin in inches” p. 1647

Docs from http://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/

See also http://msdn.microsoft.com/en-us/library/dd560821(v=office.12).aspx

dxa: The main unit in OOXML is a twentieth of a point. Also called twips. pt: point. In Excel there are 72 points to an inch hp: half-points are used to specify font sizes. A font-size of 12pt equals 24 half points pct: Half-points are used to specify font sizes. A font-size of 12pt equals 24 half points

EMU: English Metric Unit, EMUs are used for coordinates in vector-based drawings and embedded pictures. One inch equates to 914400 EMUs and a centimeter is 360000. For bitmaps the default resolution is 96 dpi (known as PixelsPerInch in Excel). Spec p. 1122

For radial geometry Excel uses integer units of 1/60000th of a degree.

openpyxl.utils.units.EMU_to_cm(value)[source]
openpyxl.utils.units.EMU_to_inch(value)[source]
openpyxl.utils.units.EMU_to_pixels(value)[source]
openpyxl.utils.units.angle_to_degrees(value)[source]
openpyxl.utils.units.cm_to_EMU(value)[source]

1 cm = 360000 EMUs

openpyxl.utils.units.cm_to_dxa(value)[source]
openpyxl.utils.units.degrees_to_angle(value)[source]

1 degree = 60000 angles

openpyxl.utils.units.dxa_to_cm(value)[source]
openpyxl.utils.units.dxa_to_inch(value)[source]
openpyxl.utils.units.inch_to_EMU(value)[source]

1 inch = 914400 EMUs

openpyxl.utils.units.inch_to_dxa(value)[source]

1 inch = 72 * 20 dxa

openpyxl.utils.units.pixels_to_EMU(value)[source]

1 pixel = 9525 EMUs

openpyxl.utils.units.pixels_to_points(value, dpi=96)[source]

96 dpi, 72i

openpyxl.utils.units.points_to_pixels(value, dpi=96)[source]
openpyxl.utils.units.short_color(color)[source]

format a color to its short size

openpyxl.workbook package
Subpackages
Submodules
openpyxl.workbook.child module
openpyxl.workbook.child.avoid_duplicate_name(names, value)[source]

Naive check to see whether name already exists. If name does exist suggest a name using an incrementer Duplicates are case insensitive

openpyxl.workbook.defined_name module
class openpyxl.workbook.defined_name.DefinedName(name=None, comment=None, customMenu=None, description=None, help=None, statusBar=None, localSheetId=None, hidden=None, function=None, vbProcedure=None, xlm=None, functionGroupId=None, shortcutKey=None, publishToServer=None, workbookParameter=None, attr_text=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

attr_text
comment

Values must be of type <class ‘str’>

customMenu

Values must be of type <class ‘str’>

description

Values must be of type <class ‘str’>

destinations
function

Values must be of type <class ‘bool’>

functionGroupId

Values must be of type <class ‘int’>

help

Values must be of type <class ‘str’>

hidden

Values must be of type <class ‘bool’>

is_external
is_reserved
localSheetId

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

publishToServer

Values must be of type <class ‘bool’>

shortcutKey

Values must be of type <class ‘str’>

statusBar

Values must be of type <class ‘str’>

tagname = 'definedName'
type
value

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

vbProcedure

Values must be of type <class ‘bool’>

workbookParameter

Values must be of type <class ‘bool’>

xlm

Values must be of type <class ‘bool’>

class openpyxl.workbook.defined_name.DefinedNameDict[source]

Bases: dict

Utility class for storing defined names. Allows access by name and separation of global and scoped names

add(value)[source]

Add names without worrying about key and name matching.

class openpyxl.workbook.defined_name.DefinedNameList(definedName=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

by_sheet()[source]

Break names down into sheet locals and globals

definedName

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'definedNames'
openpyxl.workbook.external_reference module
class openpyxl.workbook.external_reference.ExternalReference(id)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

tagname = 'externalReference'
openpyxl.workbook.function_group module
class openpyxl.workbook.function_group.FunctionGroup(name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

tagname = 'functionGroup'
class openpyxl.workbook.function_group.FunctionGroupList(builtInGroupCount=16, functionGroup=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

builtInGroupCount

Values must be of type <class ‘int’>

functionGroup

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'functionGroups'
openpyxl.workbook.properties module
class openpyxl.workbook.properties.CalcProperties(calcId=124519, calcMode=None, fullCalcOnLoad=True, refMode=None, iterate=None, iterateCount=None, iterateDelta=None, fullPrecision=None, calcCompleted=None, calcOnSave=None, concurrentCalc=None, concurrentManualCount=None, forceFullCalc=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

calcCompleted

Values must be of type <class ‘bool’>

calcId

Values must be of type <class ‘int’>

calcMode

Value must be one of {‘auto’, ‘manual’, ‘autoNoTable’}

calcOnSave

Values must be of type <class ‘bool’>

concurrentCalc

Values must be of type <class ‘bool’>

concurrentManualCount

Values must be of type <class ‘int’>

forceFullCalc

Values must be of type <class ‘bool’>

fullCalcOnLoad

Values must be of type <class ‘bool’>

fullPrecision

Values must be of type <class ‘bool’>

iterate

Values must be of type <class ‘bool’>

iterateCount

Values must be of type <class ‘int’>

iterateDelta

Values must be of type <class ‘float’>

refMode

Value must be one of {‘A1’, ‘R1C1’}

tagname = 'calcPr'
class openpyxl.workbook.properties.FileVersion(appName=None, lastEdited=None, lowestEdited=None, rupBuild=None, codeName=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

appName

Values must be of type <class ‘str’>

codeName
lastEdited

Values must be of type <class ‘str’>

lowestEdited

Values must be of type <class ‘str’>

rupBuild

Values must be of type <class ‘str’>

tagname = 'fileVersion'
class openpyxl.workbook.properties.WorkbookProperties(date1904=None, dateCompatibility=None, showObjects=None, showBorderUnselectedTables=None, filterPrivacy=None, promptedSolutions=None, showInkAnnotation=None, backupFile=None, saveExternalLinkValues=None, updateLinks=None, codeName=None, hidePivotFieldList=None, showPivotChartFilter=None, allowRefreshQuery=None, publishItems=None, checkCompatibility=None, autoCompressPictures=None, refreshAllConnections=None, defaultThemeVersion=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

allowRefreshQuery

Values must be of type <class ‘bool’>

autoCompressPictures

Values must be of type <class ‘bool’>

backupFile

Values must be of type <class ‘bool’>

checkCompatibility

Values must be of type <class ‘bool’>

codeName

Values must be of type <class ‘str’>

date1904

Values must be of type <class ‘bool’>

dateCompatibility

Values must be of type <class ‘bool’>

defaultThemeVersion

Values must be of type <class ‘int’>

filterPrivacy

Values must be of type <class ‘bool’>

hidePivotFieldList

Values must be of type <class ‘bool’>

promptedSolutions

Values must be of type <class ‘bool’>

publishItems

Values must be of type <class ‘bool’>

refreshAllConnections

Values must be of type <class ‘bool’>

saveExternalLinkValues

Values must be of type <class ‘bool’>

showBorderUnselectedTables

Values must be of type <class ‘bool’>

showInkAnnotation

Values must be of type <class ‘bool’>

showObjects

Value must be one of {‘placeholders’, ‘all’}

showPivotChartFilter

Values must be of type <class ‘bool’>

tagname = 'workbookPr'

Value must be one of {‘never’, ‘userSet’, ‘always’}

openpyxl.workbook.protection module
openpyxl.workbook.protection.DocumentSecurity

alias of openpyxl.workbook.protection.WorkbookProtection

class openpyxl.workbook.protection.FileSharing(readOnlyRecommended=None, userName=None, reservationPassword=None, algorithmName=None, hashValue=None, saltValue=None, spinCount=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

algorithmName

Values must be of type <class ‘str’>

hashValue
readOnlyRecommended

Values must be of type <class ‘bool’>

reservationPassword
saltValue
spinCount

Values must be of type <class ‘int’>

tagname = 'fileSharing'
userName

Values must be of type <class ‘str’>

class openpyxl.workbook.protection.WorkbookProtection(workbookPassword=None, workbookPasswordCharacterSet=None, revisionsPassword=None, revisionsPasswordCharacterSet=None, lockStructure=None, lockWindows=None, lockRevision=None, revisionsAlgorithmName=None, revisionsHashValue=None, revisionsSaltValue=None, revisionsSpinCount=None, workbookAlgorithmName=None, workbookHashValue=None, workbookSaltValue=None, workbookSpinCount=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

classmethod from_tree(node)[source]

Don’t hash passwords when deserialising from XML

lockRevision

Values must be of type <class ‘bool’>

lockStructure

Values must be of type <class ‘bool’>

lockWindows

Values must be of type <class ‘bool’>

lock_revision

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

lock_structure

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

lock_windows

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

revision_password

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

revisionsAlgorithmName

Values must be of type <class ‘str’>

revisionsHashValue
revisionsPassword

Return the revisions password value, regardless of hash.

revisionsPasswordCharacterSet

Values must be of type <class ‘str’>

revisionsSaltValue
revisionsSpinCount

Values must be of type <class ‘int’>

set_revisions_password(value='', already_hashed=False)[source]

Set a revision password on this workbook.

set_workbook_password(value='', already_hashed=False)[source]

Set a password on this workbook.

tagname = 'workbookPr'
workbookAlgorithmName

Values must be of type <class ‘str’>

workbookHashValue
workbookPassword

Return the workbook password value, regardless of hash.

workbookPasswordCharacterSet

Values must be of type <class ‘str’>

workbookSaltValue
workbookSpinCount

Values must be of type <class ‘int’>

workbook_password

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

openpyxl.workbook.smart_tags module
class openpyxl.workbook.smart_tags.SmartTag(namespaceUri=None, name=None, url=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

namespaceUri

Values must be of type <class ‘str’>

tagname = 'smartTagType'
url

Values must be of type <class ‘str’>

class openpyxl.workbook.smart_tags.SmartTagList(smartTagType=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

smartTagType

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'smartTagTypes'
class openpyxl.workbook.smart_tags.SmartTagProperties(embed=None, show=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

embed

Values must be of type <class ‘bool’>

show

Value must be one of {‘noIndicator’, ‘all’}

tagname = 'smartTagPr'
openpyxl.workbook.views module
class openpyxl.workbook.views.BookView(visibility='visible', minimized=False, showHorizontalScroll=True, showVerticalScroll=True, showSheetTabs=True, xWindow=None, yWindow=None, windowWidth=None, windowHeight=None, tabRatio=600, firstSheet=0, activeTab=0, autoFilterDateGrouping=True, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

activeTab

Values must be of type <class ‘int’>

autoFilterDateGrouping

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

firstSheet

Values must be of type <class ‘int’>

minimized

Values must be of type <class ‘bool’>

showHorizontalScroll

Values must be of type <class ‘bool’>

showSheetTabs

Values must be of type <class ‘bool’>

showVerticalScroll

Values must be of type <class ‘bool’>

tabRatio

Values must be of type <class ‘int’>

tagname = 'workbookView'
visibility

Value must be one of {‘visible’, ‘hidden’, ‘veryHidden’}

windowHeight

Values must be of type <class ‘int’>

windowWidth

Values must be of type <class ‘int’>

xWindow

Values must be of type <class ‘int’>

yWindow

Values must be of type <class ‘int’>

class openpyxl.workbook.views.CustomWorkbookView(name=None, guid=None, autoUpdate=None, mergeInterval=None, changesSavedWin=None, onlySync=None, personalView=None, includePrintSettings=None, includeHiddenRowCol=None, maximized=None, minimized=None, showHorizontalScroll=None, showVerticalScroll=None, showSheetTabs=None, xWindow=None, yWindow=None, windowWidth=None, windowHeight=None, tabRatio=None, activeSheetId=None, showFormulaBar=None, showStatusbar=None, showComments='commIndicator', showObjects='all', extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

activeSheetId

Values must be of type <class ‘int’>

autoUpdate

Values must be of type <class ‘bool’>

changesSavedWin

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

guid
includeHiddenRowCol

Values must be of type <class ‘bool’>

includePrintSettings

Values must be of type <class ‘bool’>

maximized

Values must be of type <class ‘bool’>

mergeInterval

Values must be of type <class ‘int’>

minimized

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

onlySync

Values must be of type <class ‘bool’>

personalView

Values must be of type <class ‘bool’>

showComments

Value must be one of {‘commNone’, ‘commIndicator’, ‘commIndAndComment’}

showFormulaBar

Values must be of type <class ‘bool’>

showHorizontalScroll

Values must be of type <class ‘bool’>

showObjects

Value must be one of {‘placeholders’, ‘all’}

showSheetTabs

Values must be of type <class ‘bool’>

showStatusbar

Values must be of type <class ‘bool’>

showVerticalScroll

Values must be of type <class ‘bool’>

tabRatio

Values must be of type <class ‘int’>

tagname = 'customWorkbookView'
windowHeight

Values must be of type <class ‘int’>

windowWidth

Values must be of type <class ‘int’>

xWindow

Values must be of type <class ‘int’>

yWindow

Values must be of type <class ‘int’>

openpyxl.workbook.web module
class openpyxl.workbook.web.WebPublishObject(id=None, divId=None, sourceObject=None, destinationFile=None, title=None, autoRepublish=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoRepublish

Values must be of type <class ‘bool’>

destinationFile

Values must be of type <class ‘str’>

divId

Values must be of type <class ‘str’>

id

Values must be of type <class ‘int’>

sourceObject

Values must be of type <class ‘str’>

tagname = 'webPublishingObject'
title

Values must be of type <class ‘str’>

class openpyxl.workbook.web.WebPublishObjectList(count=None, webPublishObject=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
tagname = 'webPublishingObjects'
webPublishObject

A sequence (list or tuple) that may only contain objects of the declared type

class openpyxl.workbook.web.WebPublishing(css=None, thicket=None, longFileNames=None, vml=None, allowPng=None, targetScreenSize='800x600', dpi=None, codePage=None, characterSet=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

allowPng

Values must be of type <class ‘bool’>

characterSet

Values must be of type <class ‘str’>

codePage

Values must be of type <class ‘int’>

css

Values must be of type <class ‘bool’>

dpi

Values must be of type <class ‘int’>

longFileNames

Values must be of type <class ‘bool’>

tagname = 'webPublishing'
targetScreenSize

Value must be one of {‘640x480’, ‘1152x882’, ‘1152x900’, ‘1600x1200’, ‘544x376’, ‘1280x1024’, ‘800x600’, ‘1800x1440’, ‘1920x1200’, ‘720x512’, ‘1024x768’}

thicket

Values must be of type <class ‘bool’>

vml

Values must be of type <class ‘bool’>

openpyxl.workbook.workbook module

Workbook is the top-level container for all document information.

class openpyxl.workbook.workbook.Workbook(write_only=False, iso_dates=False)[source]

Bases: object

Workbook is the container for all other parts of the document.

active

Get the currently active sheet or None

Type:openpyxl.worksheet.worksheet.Worksheet
add_named_style(style)[source]

Add a named style

chartsheets

A list of Chartsheets in this workbook

Type:list of openpyxl.chartsheet.chartsheet.Chartsheet
close()[source]

Close workbook file if open. Only affects read-only and write-only modes.

copy_worksheet(from_worksheet)[source]

Copy an existing worksheet in the current workbook

Warning

This function cannot copy worksheets between workbooks. worksheets can only be copied within the workbook that they belong

Parameters:from_worksheet – the worksheet to be copied from
Returns:copy of the initial worksheet
create_chartsheet(title=None, index=None)[source]
create_named_range(name, worksheet=None, value=None, scope=None)[source]

Create a new named_range on a worksheet

Note

Deprecated: Assign scoped named ranges directly to worksheets or global ones to the workbook. Deprecated in 3.1

create_sheet(title=None, index=None)[source]

Create a worksheet (at an optional index).

Parameters:
  • title (str) – optional title of the sheet
  • index (int) – optional position at which the sheet will be inserted
data_only
epoch
excel_base_date
get_index(worksheet)[source]

Return the index of the worksheet.

Note

Deprecated: Use wb.index(worksheet)

get_sheet_by_name(name)[source]

Returns a worksheet by its name.

param name:the name of the worksheet to look for
type name:string

Note

Deprecated: Use wb[sheetname]

get_sheet_names()[source]

Note

Deprecated: Use wb.sheetnames

index(worksheet)[source]

Return the index of a worksheet.

mime_type

The mime type is determined by whether a workbook is a template or not and whether it contains macros or not. Excel requires the file extension to match but openpyxl does not enforce this.

move_sheet(sheet, offset=0)[source]

Move a sheet or sheetname

named_styles

List available named styles

path = '/xl/workbook.xml'
read_only
remove(worksheet)[source]

Remove worksheet from this workbook.

remove_sheet(worksheet)[source]

Remove worksheet from this workbook.

Note

Deprecated: Use wb.remove(worksheet) or del wb[sheetname]

save(filename)[source]

Save the current workbook under the given filename. Use this function instead of using an ExcelWriter.

Warning

When creating your workbook using write_only set to True, you will only be able to call this function once. Subsequent attempts to modify or save the file will raise an openpyxl.shared.exc.WorkbookAlreadySaved exception.

sheetnames

Returns the list of the names of worksheets in this workbook.

Names are returned in the worksheets order.

Type:list of strings
style_names

List of named styles

template = False
worksheets

A list of sheets in this workbook

Type:list of openpyxl.worksheet.worksheet.Worksheet
write_only
openpyxl.worksheet package
Submodules
openpyxl.worksheet.cell_range module
class openpyxl.worksheet.cell_range.CellRange(range_string=None, min_col=None, min_row=None, max_col=None, max_row=None, title=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Represents a range in a sheet: title and coordinates.

This object is used to perform operations on ranges, like:

  • shift, expand or shrink
  • union/intersection with another sheet range,

We can check whether a range is:

  • equal or not equal to another,
  • disjoint of another,
  • contained in another.

We can get:

  • the size of a range.
  • the range bounds (vertices)
  • the coordinates,
  • the string representation,
bottom

A list of cell coordinates that comprise the bottom of the range

bounds

Vertices of the range as a tuple

cells
cols

Return cell coordinates as columns

coord

Excel-style representation of the range

expand(right=0, down=0, left=0, up=0)[source]

Expand the range by the dimensions provided.

Parameters:
  • right (int) – expand range to the right by this number of cells
  • down (int) – expand range down by this number of cells
  • left (int) – expand range to the left by this number of cells
  • up (int) – expand range up by this number of cells
intersection(other)[source]

Return a new range with cells common to this range and other

Parameters:other (openpyxl.worksheet.cell_range.CellRange) – Other sheet range.
Returns:the intersecting sheet range.
Raise:ValueError if the other range doesn’t intersect with this range.
isdisjoint(other)[source]

Return True if this range has no cell in common with other. Ranges are disjoint if and only if their intersection is the empty range.

Parameters:other (openpyxl.worksheet.cell_range.CellRange) – Other sheet range.
Returns:True if the range has no cells in common with other.
issubset(other)[source]

Test whether every cell in this range is also in other.

Parameters:other (openpyxl.worksheet.cell_range.CellRange) – Other sheet range
Returns:True if range <= other.
issuperset(other)[source]

Test whether every cell in other is in this range.

Parameters:other (openpyxl.worksheet.cell_range.CellRange) – Other sheet range
Returns:True if range >= other (or other in range).
left

A list of cell coordinates that comprise the left-side of the range

max_col

Values must be of type <class ‘int’>

max_row

Values must be of type <class ‘int’>

min_col

Values must be of type <class ‘int’>

min_row

Values must be of type <class ‘int’>

right

A list of cell coordinates that comprise the right-side of the range

rows

Return cell coordinates as rows

shift(col_shift=0, row_shift=0)[source]

Shift the focus of the range according to the shift values (col_shift, row_shift).

Parameters:
  • col_shift (int) – number of columns to be moved by, can be negative
  • row_shift (int) – number of rows to be moved by, can be negative
Raise:

ValueError if any row or column index < 1

shrink(right=0, bottom=0, left=0, top=0)[source]

Shrink the range by the dimensions provided.

Parameters:
  • right (int) – shrink range from the right by this number of cells
  • down (int) – shrink range from the top by this number of cells
  • left (int) – shrink range from the left by this number of cells
  • up (int) – shrink range from the bottom by this number of cells
size

Return the size of the range as a dictionary of rows and columns.

top

A list of cell coordinates that comprise the top of the range

union(other)[source]

Return the minimal superset of this range and other. This new range will contain all cells from this range, other, and any additional cells required to form a rectangular CellRange.

Parameters:other (openpyxl.worksheet.cell_range.CellRange) – Other sheet range.
Returns:a CellRange that is a superset of this and other.
class openpyxl.worksheet.cell_range.MultiCellRange(ranges={})[source]

Bases: openpyxl.descriptors.Strict

add(coord)[source]

Add a cell coordinate or CellRange

ranges

Use a set to keep values unique

remove(coord)[source]
sorted()[source]

Return a sorted list of items

openpyxl.worksheet.cell_watch module
class openpyxl.worksheet.cell_watch.CellWatch(r=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

r

Values must be of type <class ‘str’>

tagname = 'cellWatch'
class openpyxl.worksheet.cell_watch.CellWatches(cellWatch=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellWatch

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'cellWatches'
openpyxl.worksheet.controls module
class openpyxl.worksheet.controls.Control(controlPr=None, shapeId=None, name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

controlPr

Values must be of type <class ‘openpyxl.worksheet.controls.ControlProperty’>

name

Values must be of type <class ‘str’>

shapeId

Values must be of type <class ‘int’>

tagname = 'control'
class openpyxl.worksheet.controls.ControlProperty(anchor=None, locked=True, defaultSize=True, _print=True, disabled=False, recalcAlways=False, uiObject=False, autoFill=True, autoLine=True, autoPict=True, macro=None, altText=None, linkedCell=None, listFillRange=None, cf='pict', id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

altText

Values must be of type <class ‘str’>

anchor

Values must be of type <class ‘openpyxl.worksheet.ole.ObjectAnchor’>

autoFill

Values must be of type <class ‘bool’>

autoLine

Values must be of type <class ‘bool’>

autoPict

Values must be of type <class ‘bool’>

cf

Values must be of type <class ‘str’>

defaultSize

Values must be of type <class ‘bool’>

disabled

Values must be of type <class ‘bool’>

id

Values must be of type <class ‘str’>

linkedCell

Values must be of type <class ‘str’>

listFillRange

Values must be of type <class ‘str’>

locked

Values must be of type <class ‘bool’>

macro

Values must be of type <class ‘str’>

recalcAlways

Values must be of type <class ‘bool’>

tagname = 'controlPr'
uiObject

Values must be of type <class ‘bool’>

class openpyxl.worksheet.controls.Controls(control=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

control

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'controls'
openpyxl.worksheet.copier module
class openpyxl.worksheet.copier.WorksheetCopy(source_worksheet, target_worksheet)[source]

Bases: object

Copy the values, styles, dimensions, merged cells, margins, and print/page setup from one worksheet to another within the same workbook.

copy_worksheet()[source]
openpyxl.worksheet.custom module
class openpyxl.worksheet.custom.CustomProperties(customPr=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customPr

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'customProperties'
class openpyxl.worksheet.custom.CustomProperty(name=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

tagname = 'customProperty'
openpyxl.worksheet.datavalidation module
class openpyxl.worksheet.datavalidation.DataValidation(type=None, formula1=None, formula2=None, showErrorMessage=False, showInputMessage=False, showDropDown=False, allowBlank=False, sqref=(), promptTitle=None, errorStyle=None, error=None, prompt=None, errorTitle=None, imeMode=None, operator=None, allow_blank=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

add(cell)[source]

Adds a cell or cell coordinate to this validator

allowBlank

Values must be of type <class ‘bool’>

allow_blank

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

cells

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

error

Values must be of type <class ‘str’>

errorStyle

Value must be one of {‘warning’, ‘information’, ‘stop’}

errorTitle

Values must be of type <class ‘str’>

formula1

Values must be of type <class ‘str’>

formula2

Values must be of type <class ‘str’>

hide_drop_down

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

imeMode

Value must be one of {‘halfHangul’, ‘fullAlpha’, ‘halfAlpha’, ‘halfKatakana’, ‘on’, ‘disabled’, ‘off’, ‘hiragana’, ‘fullKatakana’, ‘noControl’, ‘fullHangul’}

operator

Value must be one of {‘greaterThanOrEqual’, ‘equal’, ‘between’, ‘lessThan’, ‘notBetween’, ‘greaterThan’, ‘lessThanOrEqual’, ‘notEqual’}

prompt

Values must be of type <class ‘str’>

promptTitle

Values must be of type <class ‘str’>

ranges

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

showDropDown

Values must be of type <class ‘bool’>

showErrorMessage

Values must be of type <class ‘bool’>

showInputMessage

Values must be of type <class ‘bool’>

sqref

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

tagname = 'dataValidation'
type

Value must be one of {‘textLength’, ‘time’, ‘list’, ‘whole’, ‘custom’, ‘date’, ‘decimal’}

validation_type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.worksheet.datavalidation.DataValidationList(disablePrompts=None, xWindow=None, yWindow=None, count=None, dataValidation=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

append(dv)[source]
count
dataValidation

A sequence (list or tuple) that may only contain objects of the declared type

disablePrompts

Values must be of type <class ‘bool’>

tagname = 'dataValidations'
to_tree(tagname=None)[source]

Need to skip validations that have no cell ranges

xWindow

Values must be of type <class ‘int’>

yWindow

Values must be of type <class ‘int’>

openpyxl.worksheet.datavalidation.collapse_cell_addresses(cells, input_ranges=())[source]

Collapse a collection of cell co-ordinates down into an optimal range or collection of ranges.

E.g. Cells A1, A2, A3, B1, B2 and B3 should have the data-validation object applied, attempt to collapse down to a single range, A1:B3.

Currently only collapsing contiguous vertical ranges (i.e. above example results in A1:A3 B1:B3).

openpyxl.worksheet.datavalidation.expand_cell_ranges(range_string)[source]

Expand cell ranges to a sequence of addresses. Reverse of collapse_cell_addresses Eg. converts “A1:A2 B1:B2” to (A1, A2, B1, B2)

openpyxl.worksheet.dimensions module
class openpyxl.worksheet.dimensions.ColumnDimension(worksheet, index='A', width=13, bestFit=False, hidden=False, outlineLevel=0, outline_level=None, collapsed=False, style=None, min=None, max=None, customWidth=False, visible=None, auto_size=None)[source]

Bases: openpyxl.worksheet.dimensions.Dimension

Information about the display properties of a column.

auto_size

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

bestFit

Values must be of type <class ‘bool’>

collapsed

Values must be of type <class ‘bool’>

customWidth

Always true if there is a width for the column

index

Values must be of type <class ‘str’>

max

Values must be of type <class ‘int’>

min

Values must be of type <class ‘int’>

reindex()[source]

Set boundaries for column definition

to_tree()[source]
width

Values must be of type <class ‘float’>

class openpyxl.worksheet.dimensions.Dimension(index, hidden, outlineLevel, collapsed, worksheet, visible=True, style=None)[source]

Bases: openpyxl.descriptors.Strict, openpyxl.styles.styleable.StyleableObject

Information about the display properties of a row or column.

collapsed

Values must be of type <class ‘bool’>

hidden

Values must be of type <class ‘bool’>

index

Values must be of type <class ‘int’>

outlineLevel

Values must be of type <class ‘int’>

outline_level

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

style

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.worksheet.dimensions.DimensionHolder(worksheet, reference='index', default_factory=None)[source]

Bases: openpyxl.utils.bound_dictionary.BoundDictionary

Allow columns to be grouped

group(start, end=None, outline_level=1, hidden=False)[source]

allow grouping a range of consecutive rows or columns together

Parameters:
  • start – first row or column to be grouped (mandatory)
  • end – last row or column to be grouped (optional, default to start)
  • outline_level – outline level
  • hidden – should the group be hidden on workbook open or not
to_tree()[source]
class openpyxl.worksheet.dimensions.RowDimension(worksheet, index=0, ht=None, customHeight=None, s=None, customFormat=None, hidden=False, outlineLevel=0, outline_level=None, collapsed=False, visible=None, height=None, r=None, spans=None, thickBot=None, thickTop=None, **kw)[source]

Bases: openpyxl.worksheet.dimensions.Dimension

Information about the display properties of a row.

customFormat

Always true if there is a style for the row

customHeight

Always true if there is a height for the row

height

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

ht

Values must be of type <class ‘float’>

r

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

s

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

thickBot

Values must be of type <class ‘bool’>

thickTop

Values must be of type <class ‘bool’>

class openpyxl.worksheet.dimensions.SheetDimension(ref=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

boundaries
ref

Values must be of type <class ‘str’>

tagname = 'dimension'
class openpyxl.worksheet.dimensions.SheetFormatProperties(baseColWidth=8, defaultColWidth=None, defaultRowHeight=15, customHeight=None, zeroHeight=None, thickTop=None, thickBottom=None, outlineLevelRow=None, outlineLevelCol=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

baseColWidth

Values must be of type <class ‘int’>

customHeight

Values must be of type <class ‘bool’>

defaultColWidth

Values must be of type <class ‘float’>

defaultRowHeight

Values must be of type <class ‘float’>

outlineLevelCol

Values must be of type <class ‘int’>

outlineLevelRow

Values must be of type <class ‘int’>

tagname = 'sheetFormatPr'
thickBottom

Values must be of type <class ‘bool’>

thickTop

Values must be of type <class ‘bool’>

zeroHeight

Values must be of type <class ‘bool’>

openpyxl.worksheet.drawing module
class openpyxl.worksheet.drawing.Drawing(id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

tagname = 'drawing'
openpyxl.worksheet.errors module
class openpyxl.worksheet.errors.Extension(uri=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'extension'
uri

Values must be of type <class ‘str’>

class openpyxl.worksheet.errors.ExtensionList(ext=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

ext

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'extensionList'
class openpyxl.worksheet.errors.IgnoredError(sqref=None, evalError=False, twoDigitTextYear=False, numberStoredAsText=False, formula=False, formulaRange=False, unlockedFormula=False, emptyCellReference=False, listDataValidation=False, calculatedColumn=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

calculatedColumn

Values must be of type <class ‘bool’>

emptyCellReference

Values must be of type <class ‘bool’>

evalError

Values must be of type <class ‘bool’>

formula

Values must be of type <class ‘bool’>

formulaRange

Values must be of type <class ‘bool’>

listDataValidation

Values must be of type <class ‘bool’>

numberStoredAsText

Values must be of type <class ‘bool’>

sqref

alias of openpyxl.descriptors.excel.CellRange

tagname = 'ignoredError'
twoDigitTextYear

Values must be of type <class ‘bool’>

unlockedFormula

Values must be of type <class ‘bool’>

class openpyxl.worksheet.errors.IgnoredErrors(ignoredError=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.worksheet.errors.ExtensionList’>

ignoredError

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'ignoredErrors'
openpyxl.worksheet.filters module
class openpyxl.worksheet.filters.AutoFilter(ref=None, filterColumn=(), sortState=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

add_filter_column(col_id, vals, blank=False)[source]

Add row filter for specified column.

Parameters:
  • col_id (int) – Zero-origin column id. 0 means first column.
  • vals (str[]) – Value list to show.
  • blank (bool) – Show rows that have blank cell if True (default=``False``)
add_sort_condition(ref, descending=False)[source]

Add sort condition for cpecified range of cells.

Parameters:
  • ref (string, is the same as that of the filter) – range of the cells (e.g. ‘A2:A150’)
  • descending (bool) – Descending sort order (default=``False``)
extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

filterColumn

A sequence (list or tuple) that may only contain objects of the declared type

ref
sortState

Values must be of type <class ‘openpyxl.worksheet.filters.SortState’>

tagname = 'autoFilter'
class openpyxl.worksheet.filters.ColorFilter(dxfId=None, cellColor=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellColor

Values must be of type <class ‘bool’>

dxfId

Values must be of type <class ‘int’>

tagname = 'colorFilter'
class openpyxl.worksheet.filters.CustomFilter(operator=None, val=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

operator

Value must be one of {‘greaterThanOrEqual’, ‘equal’, ‘lessThan’, ‘greaterThan’, ‘lessThanOrEqual’, ‘notEqual’}

tagname = 'customFilter'
val

Values must be of type <class ‘float’>

class openpyxl.worksheet.filters.CustomFilterValueDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.Convertible

Excel uses wildcards for string matching

expected_type

alias of builtins.float

pattern = re.compile('\\d+|^\\*.+|^.+\\*$')
class openpyxl.worksheet.filters.CustomFilters(_and=False, customFilter=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customFilter

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'customFilters'
class openpyxl.worksheet.filters.DateGroupItem(year=None, month=None, day=None, hour=None, minute=None, second=None, dateTimeGrouping=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

dateTimeGrouping

Value must be one of {‘second’, ‘day’, ‘month’, ‘minute’, ‘hour’, ‘year’}

day

Values must be of type <class ‘float’>

hour

Values must be of type <class ‘float’>

minute

Values must be of type <class ‘float’>

month

Values must be of type <class ‘float’>

second

Values must be of type <class ‘int’>

tagname = 'dateGroupItem'
year

Values must be of type <class ‘int’>

class openpyxl.worksheet.filters.DynamicFilter(type=None, val=None, valIso=None, maxVal=None, maxValIso=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

maxVal

Values must be of type <class ‘float’>

maxValIso

Values must be of type <class ‘datetime.datetime’>

tagname = 'dynamicFilter'
type

Value must be one of {‘M7’, ‘M3’, ‘Q2’, ‘nextWeek’, ‘thisWeek’, ‘nextMonth’, ‘yesterday’, ‘null’, ‘thisYear’, ‘nextQuarter’, ‘lastWeek’, ‘lastMonth’, ‘belowAverage’, ‘Q1’, ‘thisMonth’, ‘lastYear’, ‘yearToDate’, ‘nextYear’, ‘M1’, ‘M4’, ‘M9’, ‘M11’, ‘Q3’, ‘M12’, ‘lastQuarter’, ‘thisQuarter’, ‘aboveAverage’, ‘M5’, ‘M10’, ‘Q4’, ‘M2’, ‘M6’, ‘today’, ‘M8’, ‘tomorrow’}

val

Values must be of type <class ‘float’>

valIso

Values must be of type <class ‘datetime.datetime’>

class openpyxl.worksheet.filters.FilterColumn(colId=None, hiddenButton=False, showButton=True, filters=None, top10=None, customFilters=None, dynamicFilter=None, colorFilter=None, iconFilter=None, extLst=None, blank=None, vals=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

colId

Values must be of type <class ‘int’>

col_id

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

colorFilter

Values must be of type <class ‘openpyxl.worksheet.filters.ColorFilter’>

customFilters

Values must be of type <class ‘openpyxl.worksheet.filters.CustomFilters’>

dynamicFilter

Values must be of type <class ‘openpyxl.worksheet.filters.DynamicFilter’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

filters

Values must be of type <class ‘openpyxl.worksheet.filters.Filters’>

hiddenButton

Values must be of type <class ‘bool’>

iconFilter

Values must be of type <class ‘openpyxl.worksheet.filters.IconFilter’>

showButton

Values must be of type <class ‘bool’>

tagname = 'filterColumn'
top10

Values must be of type <class ‘openpyxl.worksheet.filters.Top10’>

class openpyxl.worksheet.filters.Filters(blank=None, calendarType=None, filter=(), dateGroupItem=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

blank

Values must be of type <class ‘bool’>

calendarType

Value must be one of {‘taiwan’, ‘hebrew’, ‘gregorianXlitFrench’, ‘gregorianUs’, ‘hijri’, ‘saka’, ‘gregorianArabic’, ‘japan’, ‘gregorianMeFrench’, ‘gregorianXlitEnglish’, ‘gregorian’, ‘korea’, ‘thai’}

dateGroupItem

A sequence (list or tuple) that may only contain objects of the declared type

filter

A sequence of primitive types that are stored as a single attribute. “val” is the default attribute

tagname = 'filters'
class openpyxl.worksheet.filters.IconFilter(iconSet=None, iconId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

iconId

Values must be of type <class ‘int’>

iconSet

Value must be one of {‘3ArrowsGray’, ‘3Symbols2’, ‘3Flags’, ‘3Symbols’, ‘3Arrows’, ‘4ArrowsGray’, ‘5Arrows’, ‘5Rating’, ‘5Quarters’, ‘4TrafficLights’, ‘4Arrows’, ‘3TrafficLights2’, ‘3Signs’, ‘5ArrowsGray’, ‘4RedToBlack’, ‘3TrafficLights1’, ‘4Rating’}

tagname = 'iconFilter'
class openpyxl.worksheet.filters.SortCondition(ref=None, descending=None, sortBy=None, customList=None, dxfId=None, iconSet=None, iconId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

customList

Values must be of type <class ‘str’>

descending

Values must be of type <class ‘bool’>

dxfId

Values must be of type <class ‘int’>

iconId

Values must be of type <class ‘int’>

iconSet

Value must be one of {‘3ArrowsGray’, ‘3Symbols2’, ‘3Flags’, ‘3Symbols’, ‘3Arrows’, ‘4ArrowsGray’, ‘5Arrows’, ‘5Rating’, ‘5Quarters’, ‘4TrafficLights’, ‘4Arrows’, ‘3TrafficLights2’, ‘3Signs’, ‘5ArrowsGray’, ‘4RedToBlack’, ‘3TrafficLights1’, ‘4Rating’}

ref
sortBy

Value must be one of {‘fontColor’, ‘icon’, ‘cellColor’, ‘value’}

tagname = 'sortCondition'
class openpyxl.worksheet.filters.SortState(columnSort=None, caseSensitive=None, sortMethod=None, ref=None, sortCondition=(), extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

caseSensitive

Values must be of type <class ‘bool’>

columnSort

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

ref
sortCondition

A sequence (list or tuple) that may only contain objects of the declared type

sortMethod

Value must be one of {‘pinYin’, ‘stroke’}

tagname = 'sortState'
class openpyxl.worksheet.filters.Top10(top=None, percent=None, val=None, filterVal=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

filterVal

Values must be of type <class ‘float’>

percent

Values must be of type <class ‘bool’>

tagname = 'top10'
top

Values must be of type <class ‘bool’>

val

Values must be of type <class ‘float’>

openpyxl.worksheet.formula module
class openpyxl.worksheet.formula.ArrayFormula(ref, text=None)[source]

Bases: object

t = 'array'
class openpyxl.worksheet.formula.DataTableFormula(ref, ca=False, dt2D=False, dtr=False, r1=None, r2=None, del1=False, del2=False, **kw)[source]

Bases: object

t = 'dataTable'
openpyxl.worksheet.merge module
class openpyxl.worksheet.merge.MergeCell(ref=None)[source]

Bases: openpyxl.worksheet.cell_range.CellRange

ref

Excel-style representation of the range

tagname = 'mergeCell'
class openpyxl.worksheet.merge.MergeCells(count=None, mergeCell=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count
mergeCell

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'mergeCells'
class openpyxl.worksheet.merge.MergedCellRange(worksheet, coord)[source]

Bases: openpyxl.worksheet.cell_range.CellRange

MergedCellRange stores the border information of a merged cell in the top left cell of the merged cell. The remaining cells in the merged cell are stored as MergedCell objects and get their border information from the upper left cell.

format()[source]

Each cell of the merged cell is created as MergedCell if it does not already exist.

The MergedCells at the edge of the merged cell gets its borders from the upper left cell.

  • The top MergedCells get the top border from the top left cell.
  • The bottom MergedCells get the bottom border from the top left cell.
  • The left MergedCells get the left border from the top left cell.
  • The right MergedCells get the right border from the top left cell.
openpyxl.worksheet.ole module
class openpyxl.worksheet.ole.ObjectAnchor(_from=None, to=None, moveWithCells=False, sizeWithCells=False, z_order=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

moveWithCells

Values must be of type <class ‘bool’>

sizeWithCells

Values must be of type <class ‘bool’>

tagname = 'anchor'
to

Values must be of type <class ‘openpyxl.drawing.spreadsheet_drawing.AnchorMarker’>

z_order

Values must be of type <class ‘int’>

class openpyxl.worksheet.ole.ObjectPr(anchor=None, locked=True, defaultSize=True, _print=True, disabled=False, uiObject=False, autoFill=True, autoLine=True, autoPict=True, macro=None, altText=None, dde=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

altText

Values must be of type <class ‘str’>

anchor

Values must be of type <class ‘openpyxl.worksheet.ole.ObjectAnchor’>

autoFill

Values must be of type <class ‘bool’>

autoLine

Values must be of type <class ‘bool’>

autoPict

Values must be of type <class ‘bool’>

dde

Values must be of type <class ‘bool’>

defaultSize

Values must be of type <class ‘bool’>

disabled

Values must be of type <class ‘bool’>

locked

Values must be of type <class ‘bool’>

macro

Values must be of type <class ‘str’>

tagname = 'objectPr'
uiObject

Values must be of type <class ‘bool’>

class openpyxl.worksheet.ole.OleObject(objectPr=None, progId=None, dvAspect='DVASPECT_CONTENT', link=None, oleUpdate=None, autoLoad=False, shapeId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoLoad

Values must be of type <class ‘bool’>

dvAspect

Value must be one of {‘DVASPECT_CONTENT’, ‘DVASPECT_ICON’}

Values must be of type <class ‘str’>

objectPr

Values must be of type <class ‘openpyxl.worksheet.ole.ObjectPr’>

oleUpdate

Value must be one of {‘OLEUPDATE_ALWAYS’, ‘OLEUPDATE_ONCALL’}

progId

Values must be of type <class ‘str’>

shapeId

Values must be of type <class ‘int’>

tagname = 'oleObject'
class openpyxl.worksheet.ole.OleObjects(oleObject=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

oleObject

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'oleObjects'
openpyxl.worksheet.page module
class openpyxl.worksheet.page.PageMargins(left=0.75, right=0.75, top=1, bottom=1, header=0.5, footer=0.5)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Information about page margins for view/print layouts. Standard values (in inches) left, right = 0.75 top, bottom = 1 header, footer = 0.5

bottom

Values must be of type <class ‘float’>

footer

Values must be of type <class ‘float’>

header

Values must be of type <class ‘float’>

left

Values must be of type <class ‘float’>

right

Values must be of type <class ‘float’>

tagname = 'pageMargins'
top

Values must be of type <class ‘float’>

class openpyxl.worksheet.page.PrintOptions(horizontalCentered=None, verticalCentered=None, headings=None, gridLines=None, gridLinesSet=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Worksheet print options

gridLines

Values must be of type <class ‘bool’>

gridLinesSet

Values must be of type <class ‘bool’>

headings

Values must be of type <class ‘bool’>

horizontalCentered

Values must be of type <class ‘bool’>

tagname = 'printOptions'
verticalCentered

Values must be of type <class ‘bool’>

class openpyxl.worksheet.page.PrintPageSetup(worksheet=None, orientation=None, paperSize=None, scale=None, fitToHeight=None, fitToWidth=None, firstPageNumber=None, useFirstPageNumber=None, paperHeight=None, paperWidth=None, pageOrder=None, usePrinterDefaults=None, blackAndWhite=None, draft=None, cellComments=None, errors=None, horizontalDpi=None, verticalDpi=None, copies=None, id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Worksheet print page setup

autoPageBreaks
blackAndWhite

Values must be of type <class ‘bool’>

cellComments

Value must be one of {‘asDisplayed’, ‘atEnd’}

copies

Values must be of type <class ‘int’>

draft

Values must be of type <class ‘bool’>

errors

Value must be one of {‘dash’, ‘displayed’, ‘blank’, ‘NA’}

firstPageNumber

Values must be of type <class ‘int’>

fitToHeight

Values must be of type <class ‘int’>

fitToPage
fitToWidth

Values must be of type <class ‘int’>

classmethod from_tree(node)[source]

Create object from XML

horizontalDpi

Values must be of type <class ‘int’>

id

Values must be of type <class ‘str’>

orientation

Value must be one of {‘default’, ‘portrait’, ‘landscape’}

pageOrder

Value must be one of {‘downThenOver’, ‘overThenDown’}

paperHeight
paperSize

Values must be of type <class ‘int’>

paperWidth
scale

Values must be of type <class ‘int’>

sheet_properties

Proxy property

tagname = 'pageSetup'
useFirstPageNumber

Values must be of type <class ‘bool’>

usePrinterDefaults

Values must be of type <class ‘bool’>

verticalDpi

Values must be of type <class ‘int’>

openpyxl.worksheet.pagebreak module
class openpyxl.worksheet.pagebreak.Break(id=0, min=0, max=16383, man=True, pt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘int’>

man

Values must be of type <class ‘bool’>

max

Values must be of type <class ‘int’>

min

Values must be of type <class ‘int’>

pt

Values must be of type <class ‘bool’>

tagname = 'brk'
class openpyxl.worksheet.pagebreak.ColBreak(count=None, manualBreakCount=None, brk=())[source]

Bases: openpyxl.worksheet.pagebreak.RowBreak

brk

A sequence (list or tuple) that may only contain objects of the declared type

count
manualBreakCount
tagname = 'colBreaks'
openpyxl.worksheet.pagebreak.PageBreak

alias of openpyxl.worksheet.pagebreak.RowBreak

class openpyxl.worksheet.pagebreak.RowBreak(count=None, manualBreakCount=None, brk=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

append(brk=None)[source]

Add a page break

brk

A sequence (list or tuple) that may only contain objects of the declared type

count
manualBreakCount
tagname = 'rowBreaks'
openpyxl.worksheet.picture module
class openpyxl.worksheet.picture.SheetBackgroundPicture[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

tagname = 'sheetBackgroundPicture'
openpyxl.worksheet.print_settings module
class openpyxl.worksheet.print_settings.ColRange(range_string=None, min_col=None, max_col=None)[source]

Bases: openpyxl.descriptors.Strict

Represent a range of at least one column

max_col

Values must be of type <class ‘str’>

min_col

Values must be of type <class ‘str’>

class openpyxl.worksheet.print_settings.PrintArea(ranges=(), title='')[source]

Bases: openpyxl.worksheet.cell_range.MultiCellRange

classmethod from_string(value)[source]
class openpyxl.worksheet.print_settings.PrintTitles(cols=None, rows=None, title='')[source]

Bases: openpyxl.descriptors.Strict

Contains at least either a range of rows or columns

cols

Values must be of type <class ‘openpyxl.worksheet.print_settings.ColRange’>

classmethod from_string(value)[source]
rows

Values must be of type <class ‘openpyxl.worksheet.print_settings.RowRange’>

title

Values must be of type <class ‘str’>

class openpyxl.worksheet.print_settings.RowRange(range_string=None, min_row=None, max_row=None)[source]

Bases: openpyxl.descriptors.Strict

Represent a range of at least one row

max_row

Values must be of type <class ‘int’>

min_row

Values must be of type <class ‘int’>

openpyxl.worksheet.properties module

Worksheet Properties

class openpyxl.worksheet.properties.Outline(applyStyles=None, summaryBelow=None, summaryRight=None, showOutlineSymbols=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

applyStyles

Values must be of type <class ‘bool’>

showOutlineSymbols

Values must be of type <class ‘bool’>

summaryBelow

Values must be of type <class ‘bool’>

summaryRight

Values must be of type <class ‘bool’>

tagname = 'outlinePr'
class openpyxl.worksheet.properties.PageSetupProperties(autoPageBreaks=None, fitToPage=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoPageBreaks

Values must be of type <class ‘bool’>

fitToPage

Values must be of type <class ‘bool’>

tagname = 'pageSetUpPr'
class openpyxl.worksheet.properties.WorksheetProperties(codeName=None, enableFormatConditionsCalculation=None, filterMode=None, published=None, syncHorizontal=None, syncRef=None, syncVertical=None, transitionEvaluation=None, transitionEntry=None, tabColor=None, outlinePr=None, pageSetUpPr=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

codeName

Values must be of type <class ‘str’>

enableFormatConditionsCalculation

Values must be of type <class ‘bool’>

filterMode

Values must be of type <class ‘bool’>

outlinePr

Values must be of type <class ‘openpyxl.worksheet.properties.Outline’>

pageSetUpPr

Values must be of type <class ‘openpyxl.worksheet.properties.PageSetupProperties’>

published

Values must be of type <class ‘bool’>

syncHorizontal

Values must be of type <class ‘bool’>

syncRef

Values must be of type <class ‘str’>

syncVertical

Values must be of type <class ‘bool’>

tabColor

Values must be of type <class ‘openpyxl.styles.colors.Color’>

tagname = 'sheetPr'
transitionEntry

Elements

transitionEvaluation

Values must be of type <class ‘bool’>

openpyxl.worksheet.protection module
class openpyxl.worksheet.protection.SheetProtection(sheet=False, objects=False, scenarios=False, formatCells=True, formatRows=True, formatColumns=True, insertColumns=True, insertRows=True, insertHyperlinks=True, deleteColumns=True, deleteRows=True, selectLockedCells=False, selectUnlockedCells=False, sort=True, autoFilter=True, pivotTables=True, password=None, algorithmName=None, saltValue=None, spinCount=None, hashValue=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable, openpyxl.worksheet.protection._Protected

Information about protection of various aspects of a sheet. True values mean that protection for the object or action is active This is the default when protection is active, ie. users cannot do something

algorithmName

Values must be of type <class ‘str’>

autoFilter

Values must be of type <class ‘bool’>

deleteColumns

Values must be of type <class ‘bool’>

deleteRows

Values must be of type <class ‘bool’>

disable()[source]
enable()[source]
enabled

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

formatCells

Values must be of type <class ‘bool’>

formatColumns

Values must be of type <class ‘bool’>

formatRows

Values must be of type <class ‘bool’>

hashValue
insertColumns

Values must be of type <class ‘bool’>

Values must be of type <class ‘bool’>

insertRows

Values must be of type <class ‘bool’>

objects

Values must be of type <class ‘bool’>

pivotTables

Values must be of type <class ‘bool’>

saltValue
scenarios

Values must be of type <class ‘bool’>

selectLockedCells

Values must be of type <class ‘bool’>

selectUnlockedCells

Values must be of type <class ‘bool’>

set_password(value='', already_hashed=False)[source]

Set a password on this sheet.

sheet

Values must be of type <class ‘bool’>

sort

Values must be of type <class ‘bool’>

spinCount

Values must be of type <class ‘int’>

tagname = 'sheetProtection'
openpyxl.worksheet.related module
class openpyxl.worksheet.related.Related(id=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

id

Values must be of type <class ‘str’>

to_tree(tagname, idx=None)[source]
openpyxl.worksheet.scenario module
class openpyxl.worksheet.scenario.InputCells(r=None, deleted=False, undone=False, val=None, numFmtId=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

deleted

Values must be of type <class ‘bool’>

numFmtId

Values must be of type <class ‘int’>

r

Values must be of type <class ‘str’>

tagname = 'inputCells'
undone

Values must be of type <class ‘bool’>

val

Values must be of type <class ‘str’>

class openpyxl.worksheet.scenario.Scenario(inputCells=(), name=None, locked=False, hidden=False, count=None, user=None, comment=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

comment

Values must be of type <class ‘str’>

count
hidden

Values must be of type <class ‘bool’>

inputCells

A sequence (list or tuple) that may only contain objects of the declared type

locked

Values must be of type <class ‘bool’>

name

Values must be of type <class ‘str’>

tagname = 'scenario'
user

Values must be of type <class ‘str’>

class openpyxl.worksheet.scenario.ScenarioList(scenario=(), current=None, show=None, sqref=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

append(scenario)[source]
current

Values must be of type <class ‘int’>

scenario

A sequence (list or tuple) that may only contain objects of the declared type

show

Values must be of type <class ‘int’>

sqref

Values must be of type <class ‘openpyxl.worksheet.cell_range.MultiCellRange’>

tagname = 'scenarios'
openpyxl.worksheet.smart_tag module
class openpyxl.worksheet.smart_tag.CellSmartTag(cellSmartTagPr=(), type=None, deleted=False, xmlBased=False)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellSmartTagPr

A sequence (list or tuple) that may only contain objects of the declared type

deleted

Values must be of type <class ‘bool’>

tagname = 'cellSmartTag'
type

Values must be of type <class ‘int’>

xmlBased

Values must be of type <class ‘bool’>

class openpyxl.worksheet.smart_tag.CellSmartTagPr(key=None, val=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

key

Values must be of type <class ‘str’>

tagname = 'cellSmartTagPr'
val

Values must be of type <class ‘str’>

class openpyxl.worksheet.smart_tag.CellSmartTags(cellSmartTag=(), r=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellSmartTag

A sequence (list or tuple) that may only contain objects of the declared type

r

Values must be of type <class ‘str’>

tagname = 'cellSmartTags'
class openpyxl.worksheet.smart_tag.SmartTags(cellSmartTags=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

cellSmartTags

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'smartTags'
openpyxl.worksheet.table module
class openpyxl.worksheet.table.Table(id=1, displayName=None, ref=None, name=None, comment=None, tableType=None, headerRowCount=1, insertRow=None, insertRowShift=None, totalsRowCount=None, totalsRowShown=None, published=None, headerRowDxfId=None, dataDxfId=None, totalsRowDxfId=None, headerRowBorderDxfId=None, tableBorderDxfId=None, totalsRowBorderDxfId=None, headerRowCellStyle=None, dataCellStyle=None, totalsRowCellStyle=None, connectionId=None, autoFilter=None, sortState=None, tableColumns=(), tableStyleInfo=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

autoFilter

Values must be of type <class ‘openpyxl.worksheet.filters.AutoFilter’>

column_names
comment

Values must be of type <class ‘str’>

connectionId

Values must be of type <class ‘int’>

dataCellStyle

Values must be of type <class ‘str’>

dataDxfId

Values must be of type <class ‘int’>

displayName

Values must be of type <class ‘str’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

headerRowBorderDxfId

Values must be of type <class ‘int’>

headerRowCellStyle

Values must be of type <class ‘str’>

headerRowCount

Values must be of type <class ‘int’>

headerRowDxfId

Values must be of type <class ‘int’>

id

Values must be of type <class ‘int’>

insertRow

Values must be of type <class ‘bool’>

insertRowShift

Values must be of type <class ‘bool’>

mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml'
name

Values must be of type <class ‘str’>

path

Return path within the archive

published

Values must be of type <class ‘bool’>

ref
sortState

Values must be of type <class ‘openpyxl.worksheet.filters.SortState’>

tableBorderDxfId

Values must be of type <class ‘int’>

tableColumns

Wrap a sequence in an containing object

tableStyleInfo

Values must be of type <class ‘openpyxl.worksheet.table.TableStyleInfo’>

tableType

Value must be one of {‘worksheet’, ‘queryTable’, ‘xml’}

tagname = 'table'
to_tree()[source]
totalsRowBorderDxfId

Values must be of type <class ‘int’>

totalsRowCellStyle

Values must be of type <class ‘str’>

totalsRowCount

Values must be of type <class ‘int’>

totalsRowDxfId

Values must be of type <class ‘int’>

totalsRowShown

Values must be of type <class ‘bool’>

class openpyxl.worksheet.table.TableColumn(id=None, uniqueName=None, name=None, totalsRowFunction=None, totalsRowLabel=None, queryTableFieldId=None, headerRowDxfId=None, dataDxfId=None, totalsRowDxfId=None, headerRowCellStyle=None, dataCellStyle=None, totalsRowCellStyle=None, calculatedColumnFormula=None, totalsRowFormula=None, xmlColumnPr=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

calculatedColumnFormula

Values must be of type <class ‘openpyxl.worksheet.table.TableFormula’>

dataCellStyle

Values must be of type <class ‘str’>

dataDxfId

Values must be of type <class ‘int’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

classmethod from_tree(node)[source]

Create object from XML

headerRowCellStyle

Values must be of type <class ‘str’>

headerRowDxfId

Values must be of type <class ‘int’>

id

Values must be of type <class ‘int’>

name

Values must be of type <class ‘str’>

queryTableFieldId

Values must be of type <class ‘int’>

tagname = 'tableColumn'
totalsRowCellStyle

Values must be of type <class ‘str’>

totalsRowDxfId

Values must be of type <class ‘int’>

totalsRowFormula

Values must be of type <class ‘openpyxl.worksheet.table.TableFormula’>

totalsRowFunction

Value must be one of {‘count’, ‘average’, ‘countNums’, ‘sum’, ‘min’, ‘max’, ‘stdDev’, ‘custom’, ‘var’}

totalsRowLabel

Values must be of type <class ‘str’>

uniqueName

Values must be of type <class ‘str’>

xmlColumnPr

Values must be of type <class ‘openpyxl.worksheet.table.XMLColumnProps’>

class openpyxl.worksheet.table.TableFormula(array=None, attr_text=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

array

Values must be of type <class ‘bool’>

attr_text
tagname = 'tableFormula'
text

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptive name is desired (eg. “underline” for “u”)

class openpyxl.worksheet.table.TableList[source]

Bases: dict

add(table)[source]
get(name=None, table_range=None)[source]

Return the value for key if key is in the dictionary, else default.

items() → a set-like object providing a view on D's items[source]
class openpyxl.worksheet.table.TableNameDescriptor(*args, **kw)[source]

Bases: openpyxl.descriptors.base.String

Table names cannot have spaces in them

class openpyxl.worksheet.table.TablePartList(count=None, tablePart=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

append(part)[source]
count
tablePart

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'tableParts'
class openpyxl.worksheet.table.TableStyleInfo(name=None, showFirstColumn=None, showLastColumn=None, showRowStripes=None, showColumnStripes=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

name

Values must be of type <class ‘str’>

showColumnStripes

Values must be of type <class ‘bool’>

showFirstColumn

Values must be of type <class ‘bool’>

showLastColumn

Values must be of type <class ‘bool’>

showRowStripes

Values must be of type <class ‘bool’>

tagname = 'tableStyleInfo'
class openpyxl.worksheet.table.XMLColumnProps(mapId=None, xpath=None, denormalized=None, xmlDataType=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

denormalized

Values must be of type <class ‘bool’>

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

mapId

Values must be of type <class ‘int’>

tagname = 'xmlColumnPr'
xmlDataType

Values must be of type <class ‘str’>

xpath

Values must be of type <class ‘str’>

openpyxl.worksheet.views module
class openpyxl.worksheet.views.Pane(xSplit=None, ySplit=None, topLeftCell=None, activePane='topLeft', state='split')[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

activePane

Value must be one of {‘bottomRight’, ‘topLeft’, ‘bottomLeft’, ‘topRight’}

state

Value must be one of {‘frozenSplit’, ‘split’, ‘frozen’}

topLeftCell

Values must be of type <class ‘str’>

xSplit

Values must be of type <class ‘float’>

ySplit

Values must be of type <class ‘float’>

class openpyxl.worksheet.views.Selection(pane=None, activeCell='A1', activeCellId=None, sqref='A1')[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

activeCell

Values must be of type <class ‘str’>

activeCellId

Values must be of type <class ‘int’>

pane

Value must be one of {‘bottomRight’, ‘topLeft’, ‘bottomLeft’, ‘topRight’}

sqref

Values must be of type <class ‘str’>

class openpyxl.worksheet.views.SheetView(windowProtection=None, showFormulas=None, showGridLines=None, showRowColHeaders=None, showZeros=None, rightToLeft=None, tabSelected=None, showRuler=None, showOutlineSymbols=None, defaultGridColor=None, showWhiteSpace=None, view=None, topLeftCell=None, colorId=None, zoomScale=None, zoomScaleNormal=None, zoomScaleSheetLayoutView=None, zoomScalePageLayoutView=None, zoomToFit=None, workbookViewId=0, selection=None, pane=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

Information about the visible portions of this sheet.

colorId

Values must be of type <class ‘int’>

defaultGridColor

Values must be of type <class ‘bool’>

pane

Values must be of type <class ‘openpyxl.worksheet.views.Pane’>

rightToLeft

Values must be of type <class ‘bool’>

selection

A sequence (list or tuple) that may only contain objects of the declared type

showFormulas

Values must be of type <class ‘bool’>

showGridLines

Values must be of type <class ‘bool’>

showOutlineSymbols

Values must be of type <class ‘bool’>

showRowColHeaders

Values must be of type <class ‘bool’>

showRuler

Values must be of type <class ‘bool’>

showWhiteSpace

Values must be of type <class ‘bool’>

showZeros

Values must be of type <class ‘bool’>

tabSelected

Values must be of type <class ‘bool’>

tagname = 'sheetView'
topLeftCell

Values must be of type <class ‘str’>

view

Value must be one of {‘normal’, ‘pageLayout’, ‘pageBreakPreview’}

windowProtection

Values must be of type <class ‘bool’>

workbookViewId

Values must be of type <class ‘int’>

zoomScale

Values must be of type <class ‘int’>

zoomScaleNormal

Values must be of type <class ‘int’>

zoomScalePageLayoutView

Values must be of type <class ‘int’>

zoomScaleSheetLayoutView

Values must be of type <class ‘int’>

zoomToFit

Values must be of type <class ‘bool’>

class openpyxl.worksheet.views.SheetViewList(sheetView=None, extLst=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

extLst

Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>

sheetView

A sequence (list or tuple) that may only contain objects of the declared type

tagname = 'sheetViews'
openpyxl.worksheet.worksheet module

Worksheet is the 2nd-level container in Excel.

class openpyxl.worksheet.worksheet.Worksheet(parent, title=None)[source]

Bases: openpyxl.workbook.child._WorkbookChild

Represents a worksheet.

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

BREAK_COLUMN = 2
BREAK_NONE = 0
BREAK_ROW = 1
ORIENTATION_LANDSCAPE = 'landscape'
ORIENTATION_PORTRAIT = 'portrait'
PAPERSIZE_A3 = '8'
PAPERSIZE_A4 = '9'
PAPERSIZE_A4_SMALL = '10'
PAPERSIZE_A5 = '11'
PAPERSIZE_EXECUTIVE = '7'
PAPERSIZE_LEDGER = '4'
PAPERSIZE_LETTER = '1'
PAPERSIZE_LETTER_SMALL = '2'
PAPERSIZE_STATEMENT = '6'
PAPERSIZE_TABLOID = '3'
SHEETSTATE_HIDDEN = 'hidden'
SHEETSTATE_VERYHIDDEN = 'veryHidden'
SHEETSTATE_VISIBLE = 'visible'
active_cell
add_chart(chart, anchor=None)[source]

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

add_data_validation(data_validation)[source]

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.

add_image(img, anchor=None)[source]

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

add_pivot(pivot)[source]
add_table(table)[source]

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

append(iterable)[source]

Appends a group of values at the bottom of the current sheet.

  • If it’s a list: all values are added in order, starting from the first column
  • If it’s a dict: values are assigned to the columns indicated by the keys (numbers or letters)
Parameters:iterable (list|tuple|range|generator or dict) – list, range or generator, or dict containing values to append

Usage:

  • append([‘This is A1’, ‘This is B1’, ‘This is C1’])
  • or append({‘A’ : ‘This is A1’, ‘C’ : ‘This is C1’})
  • or append({1 : ‘This is A1’, 3 : ‘This is C1’})
Raise:TypeError when iterable is neither a list/tuple nor a dict
array_formulae

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

calculate_dimension()[source]

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

Return type:string
cell(row, column, value=None)[source]

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.

Parameters:
  • row (int) – row index of the cell (e.g. 4)
  • column (int) – column index of the cell (e.g. 3)
  • value (numeric or time or string or bool or none) – value of the cell (e.g. 5)
Return type:

openpyxl.cell.cell.Cell

columns

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

delete_cols(idx, amount=1)[source]

Delete column or columns from col==idx

delete_rows(idx, amount=1)[source]

Delete row or rows from row==idx

dimensions

Returns the result of calculate_dimension()

freeze_panes
insert_cols(idx, amount=1)[source]

Insert column or columns before col==idx

insert_rows(idx, amount=1)[source]

Insert row or rows before row==idx

iter_cols(min_col=None, max_col=None, min_row=None, max_row=None, values_only=False)[source]

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.

Parameters:
  • min_col (int) – smallest column index (1-based index)
  • min_row (int) – smallest row index (1-based index)
  • max_col (int) – largest column index (1-based index)
  • max_row (int) – largest row index (1-based index)
  • values_only (bool) – whether only cell values should be returned
Return type:

generator

iter_rows(min_row=None, max_row=None, min_col=None, max_col=None, values_only=False)[source]

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.

Parameters:
  • min_col (int) – smallest column index (1-based index)
  • min_row (int) – smallest row index (1-based index)
  • max_col (int) – largest column index (1-based index)
  • max_row (int) – largest row index (1-based index)
  • values_only (bool) – whether only cell values should be returned
Return type:

generator

max_column

The maximum column index containing data (1-based)

Type:int
max_row

The maximum row index containing data (1-based)

Type:int
merge_cells(range_string=None, start_row=None, start_column=None, end_row=None, end_column=None)[source]

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

merged_cell_ranges

Return a copy of cell ranges

Note

Deprecated: Use ws.merged_cells.ranges

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

The minimum column index containing data (1-based)

Type:int
min_row

The minimum row index containing data (1-based)

Type:int
move_range(cell_range, rows=0, cols=0, translate=False)[source]

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.

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

print_title_cols

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

print_title_rows

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

print_titles
rows

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

Type:generator
selected_cell
set_printer_settings(paper_size, orientation)[source]

Set printer settings

sheet_view
show_gridlines
tables
unmerge_cells(range_string=None, start_row=None, start_column=None, end_row=None, end_column=None)[source]

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

values

Produces all cell values in the worksheet, by row

Type:generator
openpyxl.worksheet.worksheet.isgenerator(obj)
openpyxl.writer package
Submodules
openpyxl.writer.excel module
class openpyxl.writer.excel.ExcelWriter(workbook, archive)[source]

Bases: object

Write a workbook object to an Excel file.

save()[source]

Write data into the archive.

write_data()[source]

Write the various xml files into the zip archive.

write_worksheet(ws)[source]
openpyxl.writer.excel.save_workbook(workbook, filename)[source]

Save the given workbook on the filesystem under the name filename.

Parameters:
  • workbook (openpyxl.workbook.Workbook) – the workbook to save
  • filename (string) – the path to which save the workbook
Return type:

bool

openpyxl.writer.theme module

Write the theme xml based on a fixed string.

openpyxl.writer.theme.write_theme()[source]

Write the theme xml.

openpyxl.xml package

Collection of XML resources compatible across different Python versions

openpyxl.xml.defusedxml_available()[source]
openpyxl.xml.defusedxml_env_set()[source]
openpyxl.xml.lxml_available()[source]
openpyxl.xml.lxml_env_set()[source]
Submodules
openpyxl.xml.constants module

Constants for fixed paths in a file and xml namespace urls.

openpyxl.xml.functions module

XML compatibility functions

openpyxl.xml.functions.localname(node)[source]
openpyxl.xml.functions.whitespace(node)[source]

Parsing Formulas

openpyxl supports limited parsing of formulas embedded in cells. The openpyxl.formula package contains a Tokenizer class to break formulas into their constituent tokens. Usage is as follows:

>>> from openpyxl.formula import Tokenizer
>>> tok = Tokenizer("""=IF($A$1,"then True",MAX(DEFAULT_VAL,'Sheet 2'!B1))""")
>>> print("\n".join("%12s%11s%9s" % (t.value, t.type, t.subtype) for t in tok.items))
         IF(       FUNC     OPEN
        $A$1    OPERAND    RANGE
           ,        SEP      ARG
 "then True"    OPERAND     TEXT
           ,        SEP      ARG
        MAX(       FUNC     OPEN
 DEFAULT_VAL    OPERAND    RANGE
           ,        SEP      ARG
'Sheet 2'!B1    OPERAND    RANGE
           )       FUNC    CLOSE
           )       FUNC    CLOSE

As shown above, tokens have three attributes of interest:

  • .value: The substring of the formula that produced this token
  • .type: The type of token this represents. Can be one of
    • Token.LITERAL: If the cell does not contain a formula, its value is represented by a single LITERAL token.
    • Token.OPERAND: A generic term for any value in the Excel formula. (See .subtype below for more details).
    • Token.FUNC: Function calls are broken up into tokens for the opener (e.g., SUM(), followed by the arguments, followed by the closer (i.e., )). The function name and opening parenthesis together form one FUNC token, and the matching parenthesis forms another FUNC token.
    • Token.ARRAY: Array literals (enclosed between curly braces) get two ARRAY tokens each, one for the opening { and one for the closing }.
    • Token.PAREN: When used for grouping subexpressions (and not to denote function calls), parentheses are tokenized as PAREN tokens (one per character).
    • Token.SEP: These tokens are created from either commas (,) or semicolons (;). Commas create SEP tokens when they are used to separate function arguments (e.g., SUM(a,b)) or when they are used to separate array elements (e.g., {a,b}). (They have another use as an infix operator for joining ranges). Semicolons are always used to separate rows in an array literal, so always create SEP tokens.
    • Token.OP_PRE: Designates a prefix unary operator. Its value is always + or -
    • Token.OP_IN: Designates an infix binary operator. Possible values are >=, <=, <>, =, >, <, *, /, +, -, ^, or &.
    • Token.OP_POST: Designates a postfix unary operator. Its value is always %.
    • Token.WSPACE: Created for any whitespace encountered. Its value is always a single space, regardless of how much whitespace is found.
  • .subtype: Some of the token types above use the subtype to provide additional information about the token. Possible subtypes are:
    • Token.TEXT, Token.NUMBER, Token.LOGICAL, Token.ERROR, Token.RANGE: these subtypes describe the various forms of OPERAND found in formulae. LOGICAL is either TRUE or FALSE, RANGE is either a named range or a direct reference to another range. TEXT, NUMBER, and ERROR all refer to literal values in the formula
    • Token.OPEN and Token.CLOSE: these two subtypes are used by PAREN, FUNC, and ARRAY, to describe whether the token is opening a new subexpression or closing it.
    • Token.ARG and Token.ROW: are used by the SEP tokens, to distinguish between the comma and semicolon. Commas produce tokens of subtype ARG whereas semicolons produce tokens of subtype ROW
Translating formulae from one location to another

It is possible to translate (in the mathematical sense) formulae from one location to another using the openpyxl.formulas.translate.Translator class. For example, there a range of cells B2:E7 with a sum of each row in column F:

>>> from openpyxl.formula.translate import Translator
>>> ws['F2'] = "=SUM(B2:E2)"
>>> # move the formula one colum to the right
>>> ws['G2'] = Translator("=SUM(B2:E2)", origin="F2").translate_formula("G2")
>>> ws['G2'].value
'=SUM(C2:F2)'

Note

This is limited to the same general restrictions of formulae: A1 cell-references only and no support for defined names.

3.1.2 (2023-03-11)

  • #1963 Cannot read worksheets in read-only mode with locally scoped definitions
  • #1974 Empty custom properties cause invalid files

3.1.1 (2023-02-13)

Bugfixes
  • #1881 DocumentProperties times set by module import only
  • #1947 Worksheet-specific definitions are missing

3.1.0 (2023-01-31)

New Features
  • Added support for data table formulae
  • Mapped chartspace graphical properties to charts for advanced formatting
Bugfixes
  • #1156 Table filters are always overriden
  • #1360 Can’t read some ScatterCharts if n
  • #1724 Problem with multilevel indices in dataframes
  • #1772 Problem with category indices in dataframes
  • #1786 NamedStyles share attributes - mutables gotcha
  • #1851 Allow print area to be set to None
  • #1852 Worksheet for print title and print areas can’t be found
  • #1853 Custom document properties that are strings can be empty
  • #1858 ConditionalFormatting lost when pivot table updated
  • #1864 Better handling of defined names
  • #1904 dataframe_to_rows() misalignment on multiindex
  • #1908 Ditto
  • #1912 Excel doesn’t like xmlns:space on nodes with only whitespace, which it treats as empty.
  • #1942 Exception when print areas use table references.
Pull Requests
  • PR409 Support for Rich Text in cells
  • PR411 Provide more information when workbook cannot be loaded
  • PR407 Support for Custom Document Properties
Deprecations

The following properties have been removed from worksheets: formula_attributes, page_breaks, show_summary_below, show_summary_right, page_size orientation. Client code should use the relevant objects.

Removals

The following deprecated methods have been removed from workbooks: get_named_range, add_named_range, remove_named_range. And the get_emu_dimesions from images.

3.0.10 (2022-05-19)

Bugfixes
  • #1684 Image files not closed when workbooks are saved
  • #1778 Problem with missing scope attribute in Pivot Table formats
  • #1821 Excel unhappy when multiple sorts are defined

3.0.9 (2021-09-22)

Bugfixes
  • #1284 Ignore blank ignored in existing Data Validations
  • #1539 Add support for cell protection for merged cell ranges
  • #1645 Timezone-aware datetimes raise an Exception
  • #1666 Improved normalisation of chart series
  • #1670 Catch OverflowError for out of range datetimes
  • #1708 Alignment.relativeIndent can be negative
  • #1736 Incorrect default value groupBy attribute

3.0.8 (brown bag)

Deleted because it contained breaking changes from 3.1

3.0.7 (2021-03-09)

Bugfixes
  • #1510 Problems with zero time values
  • #1588 Not possible to correctly convert excel dates to timedelta
  • #1589 Exception raised when merging cells which do not have borders all the way round.
  • #1594 Python 2 print statement in the tutorial
Pull Requests
  • PR392 Add documentation on datetime handling
  • PR393 Drop dependency on jdcal
  • PR394 Datetime rounding
  • PR395 Unify handling of 1900 epoch
  • PR397 Add explicit support for reading datetime deltas
  • PR399 Millisecond precision for datetimes

3.0.6 (2021-01-14)

Bugfixes
  • #1154 Borders in differential styles are incorrect
  • #1287 Error when opening some pivot tables
  • #1366 Resave breaks the border format in conditional formatting rules
  • #1450 Read-only workbook not closed properly if generator interrupted
  • #1547 Pandas.Multiindex.labels deprecated
  • #1552 Pandas.Multiinex not expanded correctly
  • #1557 Cannot read rows with exponents
  • #1568 numpy.float is deprecated
  • #1571 Cells without coordinate attributes not always correctly handled
Pull Requests
  • PR385 Improved handling of borders for differential styles
  • PR386 Support subclasses of datetime objects
  • PR387 Improved handling of cells without coordinates

3.0.5 (2020-08-21)

Bugfixes
  • #1413 Incorrectly consider currency format as datetime
  • #1490 Cannot copy worksheets with merged cells
  • #1492 Empty worksheets do not return generators when looping.
  • #1496 Hyperlinks duplicated on multiple saves
  • #1500 Incorrectly literal format as datetime
  • #1502 Links set to range of cells not preserved
  • #1507 Exception when opening workbook with chartsheets and tables

3.0.4 (2020-06-24)

Bugfixes
  • #844 Find tables by name
  • #1414 Worksheet protection missing in existing files
  • #1439 Exception when reading files with external images
  • #1452 Reading lots of merged cells is very slow.
  • #1455 Read support for Bubble Charts.
  • #1458 Preserve any indexed colours
  • #1473 Reading many thousand of merged cells is really slow.
  • #1474 Adding tables in write-only mode raises an exception.
Pull Requests
  • PR377 Add support for finding tables by name or range.

3.0.3 (2020-01-20)

Bugfixes
  • #1260 Exception when handling merged cells with hyperlinks
  • #1373 Problems when both lxml and defusedxml are installed
  • #1385 CFVO with incorrect values cannot be processed

3.0.2 (2019-11-25)

Bug fixes
  • #1267 DeprecationError if both defusedxml and lxml are installed
  • #1345 ws._current_row is higher than ws.max_row
  • #1365 Border bottom style is not optional when it should be
  • #1367 Empty cells in read-only, values-only mode are sometimes returned as ReadOnlyCells
  • #1368 Cannot add page breaks to existing worksheets if none exist already
Pull Requests
  • PR359 Improvements to the documentation

3.0.1 (2019-11-14)

Bugfixes
  • #1250 Cannot read empty charts.
Pull Requests
  • PR354 Fix for #1250
  • PR352 TableStyleElement is a sequence

3.0.0 (2019-09-25)

Python 3.6+ only release

2.6.4 (2019-09-25)

Final release for Python 2.7 and 3.5
Bugfixes

2.6.3 (2019-08-19)

Bugfixes
  • #1237 Fix 3D charts.
  • #1290 Minimum for holeSize in Doughnut charts too high
  • #1291 Warning for MergedCells with comments
  • #1296 Pagebreaks duplicated
  • #1309 Workbook has no default CellStyle
  • #1330 Workbooks with comments cannot be saved multiple times
Pull Requests
  • PR344 Make sure NamedStyles number formats are correctly handled

2.6.2 (2019-03-29)

Bugfixes
  • #1173 Workbook has no _date_formats attribute
  • #1190 Cannot create charts for worksheets with quotes in the title
  • #1228 MergedCells not removed when range is unmerged
  • #1232 Link to pivot table lost from charts
  • #1233 Chart colours change after saving
  • #1236 Cannot use ws.cell in read-only mode with Python 2.7

2.6.1 (2019-03-04)

Bugfixes
  • #1174 ReadOnlyCell.is_date does not work properly
  • #1175 Cannot read Google Docs spreadsheet with a Pivot Table
  • #1180 Charts created with openpyxl cannot be styled
  • #1181 Cannot handle some numpy number types
  • #1182 Exception when reading unknowable number formats
  • #1186 Only last formatting rule for a range loaded
  • #1191 Give MergedCell a value attribute
  • #1193 Cannot process worksheets with comments
  • #1197 Cannot process worksheets with both row and page breaks
  • #1204 Cannot reset dimensions in ReadOnlyWorksheets
  • #1211 Incorrect descriptor in ParagraphProperties
  • #1213 Missing hier attribute in PageField raises an exception

2.6.0 (2019-02-06)

Bugfixes
  • #1162 Exception on tables with names containing spaces.
  • #1170 Cannot save files with existing images.

2.6.-b1 (2019-01-08)

Bugfixes
  • #1141 Cannot use read-only mode with stream
  • #1143 Hyperlinks always set on A1
  • #1151 Internal row counter not initialised when reading files
  • #1152 Exception raised on out of bounds date

2.6-a1 (2018-11-21)

Major changes
  • Implement robust for merged cells so that these can be formatted the way Excel does without confusion. Thanks to Magnus Schieder.
Minor changes
  • Add support for worksheet scenarios
  • Add read support for chartsheets
  • Add method for moving ranges of cells on a worksheet
  • Drop support for Python 3.4
  • Last version to support Python 2.7
Deprecations
  • Type inference and coercion for cell values

2.5.14 (2019-01-23)

Bugfixes
  • #1150 Correct typo in LineProperties
  • #1142 Exception raised for unsupported image files
  • #1159 Exception raised when cannot find source for non-local cache object
Pull Requests
  • PR301 Add support for nested brackets to the tokeniser
  • PR303 Improvements on handling nested brackets in the tokeniser

2.5.13 (brown bag)

2.5.12 (2018-11-29)

Bugfixes
  • #1130 Overwriting default font in Normal style affects library default
  • #1133 Images not added to anchors.
  • #1134 Cannot read pivot table formats without dxId
  • #1138 Repeated registration of simple filter could lead to memory leaks
Pull Requests
  • PR300 Use defusedxml if available

2.5.11 (2018-11-21)

Pull Requests
  • PR295 Improved handling of missing rows
  • PR296 Add support for defined names to tokeniser

2.5.10 (2018-11-13)

Bugfixes
  • #1114 Empty column dimensions should not be saved.
Pull Requests
  • PR285 Tokenizer failure for quoted sheet name in second half of range
  • PR289 Improved error detection in ranges.

2.5.9 (2018-10-19)

Bugfixes
  • #1000 Clean AutoFilter name definitions
  • #1106 Attribute missing from Shape object
  • #1109 Failure to read all DrawingML means workbook can’t be read
Pull Requests
  • PR281 Allow newlines in formulae
  • PR284 Fix whitespace in front of infix operator in formulae

2.5.8 (2018-09-25)

  • #877 Cannot control how missing values are displayed in charts.
  • #948 Cell references can’t be used for chart titles
  • #1095 Params in iter_cols and iter_rows methods are slightly wrong.

2.5.7 (2018-09-13)

  • #954 Sheet title containing % need quoting in references
  • #1047 Cannot set quote prefix
  • #1093 Pandas timestamps raise KeyError

2.5.6 (2018-08-30)

  • #832 Read-only mode can leave find-handles open when reading dimensions
  • #933 Set a worksheet directly as active
  • #1086 Internal row counter not adjusted when rows are deleted or inserted

2.5.5 (2018-08-04)

Bugfixes
  • #1049 Files with Mac epoch are read incorrectly
  • #1058 Cannot copy merged cells
  • #1066 Cannot access ws.active_cell
Pull Requests
  • PR267 Introduce read-support for images

2.5.4 (2018-06-07)

Bugfixes
  • #1025 Cannot read files with 3D charts.
  • #1030 Merged cells take a long time to parse
Minor changes

2.5.3 (2018-04-18)

Bugfixes
  • #983 Warning level too aggressive.
  • #1015 Alignment and protection values not saved for named styles.
  • #1017 Deleting elements from a legend doesn’t work.
  • #1018 Index names repeated for every row in dataframe.
  • #1020 Worksheet protection not being stored.
  • #1023 Exception raised when reading a tooltip.

2.5.2 (2018-04-06)

Bugfixes
  • #949 High memory use when reading text-heavy files.
  • #970 Copying merged cells copies references.
  • #978 Cannot set comment size.
  • #985 Exception when trying to save workbooks with no views.
  • #995 Cannot delete last row or column.
  • #1002 Cannot read Drawings containing embedded images.
Minor changes
  • Support for dataframes with multiple columns and multiple indices.

2.5.1 (2018-03-12)

Bugfixes
  • #934 Headers and footers not included in write-only mode.
  • #960 Deprecation warning raised when using ad-hoc access in read-only mode.
  • #964 Not all cells removed when deleting multiple rows.
  • #966 Cannot read 3d bar chart correctly.
  • #967 Problems reading some charts.
  • #968 Worksheets with SHA protection become corrupted after saving.
  • #974 Problem when deleting ragged rows or columns.
  • #976 GroupTransforms and GroupShapeProperties have incorrect descriptors
  • Make sure that headers and footers in chartsheets are included in the file

2.5.0 (2018-01-24)

Minor changes
  • Correct definition for Connection Shapes. Related to # 958

2.5.0-b2 (2018-01-19)

Bugfixes
  • #915 TableStyleInfo has no required attributes
  • #925 Cannot read files with 3D drawings
  • #926 Incorrect version check in installer
  • Cell merging uses transposed parameters
  • #928 ExtLst missing keyword for PivotFields
  • #932 Inf causes problems for Excel
  • #952 Cannot load table styles with custom names
Major Changes
  • You can now insert and delete rows and columns in worksheets
Minor Changes
  • pip now handles which Python versions can be used.

2.5.0-b1 (2017-10-19)

Bugfixes
  • #812 Explicitly support for multiple cell ranges in conditonal formatting
  • #827 Non-contiguous cell ranges in validators get merged
  • #837 Empty data validators create invalid Excel files
  • #860 Large validation ranges use lots of memory
  • #876 Unicode in chart axes not handled correctly in Python 2
  • #882 ScatterCharts have defective axes
  • #885 Charts with empty numVal elements cannot be read
  • #894 Scaling options from existing files ignored
  • #895 Charts with PivotSource cannot be read
  • #903 Cannot read gradient fills
  • #904 Quotes in number formats could be treated as datetimes
Major Changes

worksheet.cell() no longer accepts a coordinate parameter. The syntax is now ws.cell(row, column, value=None)

Minor Changes

Added CellRange and MultiCellRange types (thanks to Laurent LaPorte for the suggestion) as a utility type for things like data validations, conditional formatting and merged cells.

Deprecations

ws.merged_cell_ranges has been deprecated because MultiCellRange provides sufficient functionality

2.5.0-a3 (2017-08-14)

Bugfixes
  • #848 Reading workbooks with Pie Charts raises an exception
  • #857 Pivot Tables without Worksheet Sources raise an exception

2.5.0-a2 (2017-06-25)

Major Changes
  • Read support for charts
Bugfixes
  • #833 Cannot access chartsheets by title
  • #834 Preserve workbook views
  • #841 Incorrect classification of a datetime

2.5.0-a1 (2017-05-30)

Compatibility
  • Dropped support for Python 2.6 and 3.3. openpyxl will not run with Python 2.6
Major Changes
  • Read/write support for pivot tables
Deprecations
  • Dropped the anchor method from images and additional constructor arguments
Bugfixes
  • #779 Fails to recognise Chinese date format`
  • #828 Include hidden cells in charts`
Pull requests
  • 163 Improved GradientFill
Minor changes
  • Remove deprecated methods from Cell
  • Remove deprecated methods from Worksheet
  • Added read/write support for the datetime type for cells

2.4.11 (2018-01-24)

2.4.10 (2018-01-19)

Bugfixes

2.4.9 (2017-10-19)

Bugfixes
  • #809 Incomplete documentation of copy_worksheet method
  • #811 Scoped definedNames not removed when worksheet is deleted
  • #824 Raise an exception if a chart is used in multiple sheets
  • #842 Non-ASCII table column headings cause an exception in Python 2
  • #846 Conditional formats not supported in write-only mode
  • #849 Conditional formats with no sqref cause an exception
  • #859 Headers that start with a number conflict with font size
  • #902 TableStyleElements don’t always have a condtional format
  • #908 Read-only mode sometimes returns too many cells
Pull requests
  • #179 Cells kept in a set
  • #180 Support for Workbook protection
  • #182 Read support for page breaks
  • #183 Improve documentation of copy_worksheet method
  • #198 Fix for #908

2.4.8 (2017-05-30)

Bugfixes
  • AutoFilter.sortState being assignd to the ws.sortState
  • #766 Sheetnames with apostrophes need additional escaping
  • #729 Cannot open files created by Microsoft Dynamics
  • #819 Negative percents not case correctly
  • #821 Runtime imports can cause deadlock
  • #855 Print area containing only columns leads to corrupt file
Minor changes
  • Preserve any table styles

2.4.7 (2017-04-24)

Bugfixes
  • #807 Sample files being included by mistake in sdist

2.4.6 (2017-04-14)

Bugfixes
  • #776 Cannot apply formatting to plot area
  • #780 Exception when element attributes are Python keywords
  • #781 Exception raised when saving files with styled columns
  • #785 Number formats for data labels are incorrect
  • #788 Worksheet titles not quoted in defined names
  • #800 Font underlines not read correctly

2.4.5 (2017-03-07)

Bugfixes
  • #750 Adding images keeps file handles open
  • #772 Exception for column-only ranges
  • #773 Cannot copy worksheets with non-ascii titles on Python 2
Pull requests
  • 161 Support for non-standard names for Workbook part.
  • 162 Documentation correction

2.4.4 (2017-02-23)

Bugfixes
  • #673 Add close method to workbooks
  • #762 openpyxl can create files with invalid style indices
  • #729 Allow images in write-only mode
  • #744 Rounded corners for charts
  • #747 Use repr when handling non-convertible objects
  • #764 Hashing function is incorrect
  • #765 Named styles share underlying array
Minor Changes
  • Add roundtrip support for worksheet tables.
Pull requests
  • 160 Don’t init mimetypes more than once.

2.4.3 (unreleased)

bad release

2.4.2 (2017-01-31)

Bug fixes
  • #727 DeprecationWarning is incorrect
  • #734 Exception raised if userName is missing
  • #739 Always provide a date1904 attribute
  • #740 Hashes should be stored as Base64
  • #743 Print titles broken on sheetnames with spaces
  • #748 Workbook breaks when active sheet is removed
  • #754 Incorrect descriptor for Filter values
  • #756 Potential XXE vulerability
  • #758 Cannot create files with page breaks and charts
  • #759 Problems with worksheets with commas in their titles
Minor Changes
  • Add unicode support for sheet name incrementation.

2.4.1 (2016-11-23)

Bug fixes
  • #643 Make checking for duplicate sheet titles case insensitive
  • #647 Trouble handling LibreOffice files with named styles
  • #687 Directly assigned new named styles always refer to “Normal”
  • #690 Cannot parse print titles with multiple sheet names
  • #691 Cannot work with macro files created by LibreOffice
  • Prevent duplicate differential styles
  • #694 Allow sheet titles longer than 31 characters
  • #697 Cannot unset hyperlinks
  • #699 Exception raised when format objects use cell references
  • #703 Copy height and width when copying comments
  • #705 Incorrect content type for VBA macros
  • #707 IndexError raised in read-only mode when accessing individual cells
  • #711 Files with external links become corrupted
  • #715 Cannot read files containing macro sheets
  • #717 Details from named styles not preserved when reading files
  • #722 Remove broken Print Title and Print Area definitions
Minor changes
  • Add support for Python 3.6
  • Correct documentation for headers and footers
Deprecations

Worksheet methods get_named_range() and get_sqaured_range()

Bug fixes

2.4.0 (2016-09-15)

Bug fixes
  • #652 Exception raised when epoch is 1904
  • #642 Cannot handle unicode in headers and footers in Python 2
  • #646 Cannot handle unicode sheetnames in Python 2
  • #658 Chart styles, and axis units should not be 0
  • #663 Strings in external workbooks not unicode
Major changes
  • Add support for builtin styles and include one for Pandas
Minor changes
  • Add a keep_links option to load_workbook. External links contain cached copies of the external workbooks. If these are big it can be advantageous to be able to disable them.
  • Provide an example for using cell ranges in DataValidation.
  • PR 138 - add copy support to comments.

2.4.0-b1 (2016-06-08)

Minor changes
  • Add an the alias hide_drop_down to DataValidation for showDropDown because that is how Excel works.
Bug fixes
  • #625 Exception raises when inspecting EmptyCells in read-only mode
  • #547 Functions for handling OOXML “escaped” ST_XStrings
  • #629 Row Dimensions not supported in write-only mode
  • #530 Problems when removing worksheets with charts
  • #630 Cannot use SheetProtection in write-only mode
Features
  • Add write support for worksheet tables

2.4.0-a1 (2016-04-11)

Minor changes
  • Remove deprecated methods from DataValidation
  • Remove deprecated methods from PrintPageSetup
  • Convert AutoFilter to Serialisable and extend support for filters
  • Add support for SortState
  • Removed use_iterators keyword when loading workbooks. Use read_only instead.
  • Removed optimized_write keyword for new workbooks. Use write_only instead.
  • Improve print title support
  • Add print area support
  • New implementation of defined names
  • New implementation of page headers and footers
  • Add support for Python’s NaN
  • Added iter_cols method for worksheets
  • ws.rows and ws.columns now always return generators and start at the top of the worksheet
  • Add a values property for worksheets
  • Default column width changed to 8 as per the specification
Deprecations
  • Cell anchor method
  • Worksheet point_pos method
  • Worksheet add_print_title method
  • Worksheet HeaderFooter attribute, replaced by individual ones
  • Flatten function for cells
  • Workbook get_named_range, add_named_range, remove_named_range, get_sheet_names, get_sheet_by_name
  • Comment text attribute
  • Use of range strings deprecated for ws.iter_rows()
  • Use of coordinates deprecated for ws.cell()
  • Deprecate .copy() method for StyleProxy objects
Bug fixes
  • #152 Hyperlinks lost when reading files
  • #171 Add function for copying worksheets
  • #386 Cells with inline strings considered empty
  • #397 Add support for ranges of rows and columns
  • #446 Workbook with definedNames corrupted by openpyxl
  • #481 “safe” reserved ranges are not read from workbooks
  • #501 Discarding named ranges can lead to corrupt files
  • #574 Exception raised when using the class method to parse Relationships
  • #579 Crashes when reading defined names with no content
  • #597 Cannot read worksheets without coordinates
  • #617 Customised named styles not correctly preserved

2.3.5 (2016-04-11)

Bug fixes
  • #618 Comments not written in write-only mode

2.3.4 (2016-03-16)

Bug fixes
  • #594 Content types might be missing when keeping VBA
  • #599 Cells with only one cell look empty
  • #607 Serialise NaN as ‘’
Minor changes
  • Preserve the order of external references because formualae use numerical indices.
  • Typo corrected in cell unit tests (PR 118)

2.3.3 (2016-01-18)

Bug fixes
  • #540 Cannot read merged cells in read-only mode
  • #565 Empty styled text blocks cannot be parsed
  • #569 Issue warning rather than raise Exception raised for unparsable definedNames
  • #575 Cannot open workbooks with embdedded OLE files
  • #584 Exception when saving borders with attributes
Minor changes
  • PR 103 Documentation about chart scaling and axis limits
  • Raise an exception when trying to copy cells from other workbooks.

2.3.2 (2015-12-07)

Bug fixes
  • #554 Cannot add comments to a worksheet when preserving VBA
  • #561 Exception when reading phonetic text
  • #562 DARKBLUE is the same as RED
  • #563 Minimum for row and column indexes not enforced
Minor changes
  • PR 97 One VML file per worksheet.
  • PR 96 Correct descriptor for CharacterProperties.rtl
  • #498 Metadata is not essential to use the package.

2.3.1 (2015-11-20)

Bug fixes
  • #534 Exception when using columns property in read-only mode.
  • #536 Incorrectly handle comments from Google Docs files.
  • #539 Flexible value types for conditional formatting.
  • #542 Missing content types for images.
  • #543 Make sure images fit containers on all OSes.
  • #544 Gracefully handle missing cell styles.
  • #546 ExternalLink duplicated when editing a file with macros.
  • #548 Exception with non-ASCII worksheet titles
  • #551 Combine multiple LineCharts
Minor changes
  • PR 88 Fix page margins in parser.

2.3.0 (2015-10-20)

Major changes
  • Support the creation of chartsheets
Bug fixes
  • #532 Problems when cells have no style in read-only mode.
Minor changes
  • PR 79 Make PlotArea editable in charts
  • Use graphicalProperties as the alias for spPr

2.3.0-b2 (2015-09-04)

Bug fixes
  • #488 Support hashValue attribute for sheetProtection
  • #493 Warn that unsupported extensions will be dropped
  • #494 Cells with exponentials causes a ValueError
  • #497 Scatter charts are broken
  • #499 Inconsistent conversion of localised datetimes
  • #500 Adding images leads to unreadable files
  • #509 Improve handling of sheet names
  • #515 Non-ascii titles have bad repr
  • #516 Ignore unassigned worksheets
Minor changes
  • Worksheets are now iterable by row.
  • Assign individual cell styles only if they are explicitly set.

2.3.0-b1 (2015-06-29)

Major changes
  • Shift to using (row, column) indexing for cells. Cells will at some point lose coordinates.
  • New implementation of conditional formatting. Databars now partially preserved.
  • et_xmlfile is now a standalone library.
  • Complete rewrite of chart package
  • Include a tokenizer for fomulae to be able to adjust cell references in them. PR 63
Minor changes
  • Read-only and write-only worksheets renamed.
  • Write-only workbooks support charts and images.
  • PR76 Prevent comment images from conflicting with VBA
Bug fixes
  • #81 Support stacked bar charts
  • #88 Charts break hyperlinks
  • #97 Pie and combination charts
  • #99 Quote worksheet names in chart references
  • #150 Support additional chart options
  • #172 Support surface charts
  • #381 Preserve named styles
  • #470 Adding more than 10 worksheets with the same name leads to duplicates sheet names and an invalid file

2.2.6 (unreleased)

Bug fixes
  • #502 Unexpected keyword “mergeCell”
  • #503 tostring missing in dump_worksheet
  • #506 Non-ASCII formulae cannot be parsed
  • #508 Cannot save files with coloured tabs
  • Regex for ignoring named ranges is wrong (character class instead of prefix)

2.2.5 (2015-06-29)

Bug fixes
  • #463 Unexpected keyword “mergeCell”
  • #484 Unusual dimensions breaks read-only mode
  • #485 Move return out of loop

2.2.4 (2015-06-17)

Bug fixes
  • #464 Cannot use images when preserving macros
  • #465 ws.cell() returns an empty cell on read-only workbooks
  • #467 Cannot edit a file with ActiveX components
  • #471 Sheet properties elements must be in order
  • #475 Do not redefine class __slots__ in subclasses
  • #477 Write-only support for SheetProtection
  • #478 Write-only support for DataValidation
  • Improved regex when checking for datetime formats

2.2.3 (2015-05-26)

Bug fixes
  • #451 fitToPage setting ignored
  • #458 Trailing spaces lost when saving files.
  • #459 setup.py install fails with Python 3
  • #462 Vestigial rId conflicts when adding charts, images or comments
  • #455 Enable Zip64 extensions for all versions of Python

2.2.2 (2015-04-28)

Bug fixes
  • #447 Uppercase datetime number formats not recognised.
  • #453 Borders broken in shared_styles.

2.2.1 (2015-03-31)

Minor changes
  • PR54 Improved precision on times near midnight.
  • PR55 Preserve macro buttons
Bug fixes
  • #429 Workbook fails to load because header and footers cannot be parsed.
  • #433 File-like object with encoding=None
  • #434 SyntaxError when writing page breaks.
  • #436 Read-only mode duplicates empty rows.
  • #437 Cell.offset raises an exception
  • #438 Cells with pivotButton and quotePrefix styles cannot be read
  • #440 Error when customised versions of builtin formats
  • #442 Exception raised when a fill element contains no children
  • #444 Styles cannot be copied

2.2.0 (2015-03-11)

Bug fixes
  • #415 Improved exception when passing in invalid in memory files.

2.2.0-b1 (2015-02-18)

Major changes
  • Cell styles deprecated, use formatting objects (fonts, fills, borders, etc.) directly instead
  • Charts will no longer try and calculate axes by default
  • Support for template file types - PR21
  • Moved ancillary functions and classes into utils package - single place of reference
  • PR 34 Fully support page setup
  • Removed SAX-based XML Generator. Special thanks to Elias Rabel for implementing xmlfile for xml.etree
  • Preserve sheet view definitions in existing files (frozen panes, zoom, etc.)
Bug fixes
  • #103 Set the zoom of a sheet
  • #199 Hide gridlines
  • #215 Preserve sheet view setings
  • #262 Set the zoom of a sheet
  • #392 Worksheet header not read
  • #387 Cannot read files without styles.xml
  • #410 Exception when preserving whitespace in strings
  • #417 Cannot create print titles
  • #420 Rename confusing constants
  • #422 Preserve color index in a workbook if it differs from the standard
Minor changes
  • Use a 2-way cache for column index lookups
  • Clean up tests in cells
  • PR 40 Support frozen panes and autofilter in write-only mode
  • Use ws.calculate_dimension(force=True) in read-only mode for unsized worksheets

2.1.5 (2015-02-18)

Bug fixes
  • #403 Cannot add comments in write-only mode
  • #401 Creating cells in an empty row raises an exception
  • #408 from_excel adjustment for Julian dates 1 < x < 60
  • #409 refersTo is an optional attribute
Minor changes
  • Allow cells to be appended to standard worksheets for code compatibility with write-only mode.

2.1.4 (2014-12-16)

Bug fixes
  • #393 IterableWorksheet skips empty cells in rows
  • #394 Date format is applied to all columns (while only first column contains dates)
  • #395 temporary files not cleaned properly
  • #396 Cannot write “=” in Excel file
  • #398 Cannot write empty rows in write-only mode with LXML installed
Minor changes
  • Add relation namespace to root element for compatibility with iWork
  • Serialize comments relation in LXML-backend

2.1.3 (2014-12-09)

Minor changes
  • PR 31 Correct tutorial
  • PR 32 See #380
  • PR 37 Bind worksheet to ColumnDimension objects
Bug fixes
  • #379 ws.append() doesn’t set RowDimension Correctly
  • #380 empty cells formatted as datetimes raise exceptions

2.1.2 (2014-10-23)

Minor changes
  • PR 30 Fix regex for positive exponentials
  • PR 28 Fix for #328
Bug fixes
  • #120, #168 defined names with formulae raise exceptions, #292
  • #328 ValueError when reading cells with hyperlinks
  • #369 IndexError when reading definedNames
  • #372 number_format not consistently applied from styles

2.1.1 (2014-10-08)

Minor changes
  • PR 20 Support different workbook code names
  • Allow auto_axis keyword for ScatterCharts
Bug fixes
  • #332 Fills lost in ConditionalFormatting
  • #360 Support value=”none” in attributes
  • #363 Support undocumented value for textRotation
  • #364 Preserve integers in read-only mode
  • #366 Complete read support for DataValidation
  • #367 Iterate over unsized worksheets

2.1.0 (2014-09-21)

Major changes
  • “read_only” and “write_only” new flags for workbooks
  • Support for reading and writing worksheet protection
  • Support for reading hidden rows
  • Cells now manage their styles directly
  • ColumnDimension and RowDimension object manage their styles directly
  • Use xmlfile for writing worksheets if available - around 3 times faster
  • Datavalidation now part of the worksheet package
Minor changes
  • Number formats are now just strings
  • Strings can be used for RGB and aRGB colours for Fonts, Fills and Borders
  • Create all style tags in a single pass
  • Performance improvement when appending rows
  • Cleaner conversion of Python to Excel values
  • PR6 reserve formatting for empty rows
  • standard worksheets can append from ranges and generators
Bug fixes
  • #153 Cannot read visibility of sheets and rows
  • #181 No content type for worksheets
  • 241 Cannot read sheets with inline strings
  • 322 1-indexing for merged cells
  • 339 Correctly handle removal of cell protection
  • 341 Cells with formulae do not round-trip
  • 347 Read DataValidations
  • 353 Support Defined Named Ranges to external workbooks

2.0.5 (2014-08-08)

Bug fixes
  • #348 incorrect casting of boolean strings
  • #349 roundtripping cells with formulae

2.0.4 (2014-06-25)

Minor changes
  • Add a sample file illustrating colours
Bug fixes
  • #331 DARKYELLOW was incorrect
  • Correctly handle extend attribute for fonts

2.0.3 (2014-05-22)

Minor changes
  • Updated docs
Bug fixes
  • #319 Cannot load Workbooks with vertAlign styling for fonts

2.0.2 (2014-05-13)

2.0.1 (2014-05-13) brown bag

2.0.0 (2014-05-13) brown bag

Major changes
  • This is last release that will support Python 3.2
  • Cells are referenced with 1-indexing: A1 == cell(row=1, column=1)
  • Use jdcal for more efficient and reliable conversion of datetimes
  • Significant speed up when reading files
  • Merged immutable styles
  • Type inference is disabled by default
  • RawCell renamed ReadOnlyCell
  • ReadOnlyCell.internal_value and ReadOnlyCell.value now behave the same as Cell
  • Provide no size information on unsized worksheets
  • Lower memory footprint when reading files
Minor changes
  • All tests converted to pytest
  • Pyflakes used for static code analysis
  • Sample code in the documentation is automatically run
  • Support GradientFills
  • BaseColWidth set
Pull requests
  • #70 Add filterColumn, sortCondition support to AutoFilter
  • #80 Reorder worksheets parts
  • #82 Update API for conditional formatting
  • #87 Add support for writing Protection styles, others
  • #89 Better handling of content types when preserving macros
Bug fixes
  • #46 ColumnDimension style error
  • #86 reader.worksheet.fast_parse sets booleans to integers
  • #98 Auto sizing column widths does not work
  • #137 Workbooks with chartsheets
  • #185 Invalid PageMargins
  • #230 Using v in cells creates invalid files
  • #243 - IndexError when loading workbook
  • #263 - Forded conversion of line breaks
  • #267 - Raise exceptions when passed invalid types
  • #270 - Cannot open files which use non-standard sheet names or reference Ids
  • #269 - Handling unsized worksheets in IterableWorksheet
  • #270 - Handling Workbooks with non-standard references
  • #275 - Handling auto filters where there are only custom filters
  • #277 - Harmonise chart and cell coordinates
  • #280- Explicit exception raising for invalid characters
  • #286 - Optimized writer can not handle a datetime.time value
  • #296 - Cell coordinates not consistent with documentation
  • #300 - Missing column width causes load_workbook() exception
  • #304 - Handling Workbooks with absolute paths for worksheets (from Sharepoint)

1.8.6 (2014-05-05)

Minor changes

Fixed typo for import Elementtree

Bugfixes
  • #279 Incorrect path for comments files on Windows

1.8.5 (2014-03-25)

Minor changes
  • The ‘=’ string is no longer interpreted as a formula
  • When a client writes empty xml tags for cells (e.g. <c r=’A1’></c>), reader will not crash

1.8.4 (2014-02-25)

Bugfixes
  • #260 better handling of undimensioned worksheets
  • #268 non-ascii in formualae
  • #282 correct implementation of register_namepsace for Python 2.6

1.8.3 (2014-02-09)

Major changes

Always parse using cElementTree

Minor changes

Slight improvements in memory use when parsing

  • #256 - error when trying to read comments with optimised reader
  • #260 - unsized worksheets
  • #264 - only numeric cells can be dates

1.8.2 (2014-01-17)

  • #247 - iterable worksheets open too many files
  • #252 - improved handling of lxml
  • #253 - better handling of unique sheetnames

1.8.1 (2014-01-14)

1.8.0 (2014-01-08)

Compatibility

Support for Python 2.5 dropped.

Major changes
  • Support conditional formatting
  • Support lxml as backend
  • Support reading and writing comments
  • pytest as testrunner now required
  • Improvements in charts: new types, more reliable
Minor changes
  • load_workbook now accepts data_only to allow extracting values only from formulae. Default is false.
  • Images can now be anchored to cells
  • Docs updated
  • Provisional benchmarking
  • Added convenience methods for accessing worksheets and cells by key

1.7.0 (2013-10-31)

Major changes

Drops support for Python < 2.5 and last version to support Python 2.5

Compatibility

Tests run on Python 2.5, 2.6, 2.7, 3.2, 3.3

Merged pull requests
  • 27 Include more metadata
  • 41 Able to read files with chart sheets
  • 45 Configurable Worksheet classes
  • 3 Correct serialisation of Decimal
  • 36 Preserve VBA macros when reading files
  • 44 Handle empty oddheader and oddFooter tags
  • 43 Fixed issue that the reader never set the active sheet
  • 33 Reader set value and type explicitly and TYPE_ERROR checking
  • 22 added page breaks, fixed formula serialization
  • 39 Fix Python 2.6 compatibility
  • 47 Improvements in styling
Miscellaneous

Performance improvements in optimised writer

Docs updated

Indices and tables