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

Author:Eric Gazoni, Charlie Clark
Source code:http://bitbucket.org/openpyxl/openpyxl/src
Issues:http://bitbucket.org/openpyxl/openpyxl/issues
Generated:Feb 04, 2019
License:MIT/Expat
Version:2.5.15
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.

How to Contribute

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

1. Please start a new fork (https://bitbucket.org/openpyxl/openpyxl/fork) 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 2.7 to 3.5, so if it does not work on your environment, let us know :-)

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://bitbucket.org/openpyxl/openpyxl@2.5#egg=openpyxl

Usage examples

Tutorial

Tutorial

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

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"

The background color of the tab holding this title is white by default. You can change this providing an RRGGBB color code to the Worksheet.sheet_properties.tabColor attribute:

ws.sheet_properties.tabColor = "1072BA"

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 attribues (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)
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 end the filename with .zip and open it with your favourite ZIP archive manager.

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

You can specify the attribute template=True, to save a workbook as a template:

>>> wb = load_workbook('document.xlsx')
>>> wb.template = True
>>> wb.save('document_template.xltx')

or set this attribute to False (default), to save as a document:

>>> wb = load_workbook('document_template.xltx')
>>> wb.template = False
>>> wb.save('document.xlsx', as_template=False)

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

The same way as writing, you can use the openpyxl.load_workbook() to open an existing workbook:

>>> from openpyxl import load_workbook
>>> wb2 = load_workbook('test.xlsx')
>>> print wb2.sheetnames
['Sheet2', 'New Title', 'Sheet1']

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

Cookbook

Simple usage

Write a workbook
>>> from openpyxl import Workbook
>>> from openpyxl.compat import range
>>> from openpyxl.utils import get_column_letter
>>>
>>> wb = Workbook()
>>>
>>> dest_filename = 'empty_book.xlsx'
>>>
>>> ws1 = wb.active
>>> ws1.title = "range names"
>>>
>>> for row in range(1, 40):
...     ws1.append(range(600))
>>>
>>> ws2 = wb.create_sheet(title="Pi")
>>>
>>> ws2['F5'] = 3.14
>>>
>>> ws3 = wb.create_sheet(title="Data")
>>> for row in range(10, 20):
...     for col in range(27, 54):
...         _ = ws3.cell(column=col, row=row, value="{0}".format(get_column_letter(col)))
>>> print(ws3['AA10'].value)
AA
>>> wb.save(filename = dest_filename)
Read 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.

  • guess_types will enable or disable (default) type inference when reading cells.
  • 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 images and charts will be lost from existing files if they are opened and saved with the same name.

Using number formats
>>> 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'
>>> # You can enable type inference on a case-by-case basis
>>> wb.guess_types = True
>>> # set percentage using a string followed by the percent sign
>>> ws['B1'] = '3.14%'
>>> wb.guess_types = False
>>> ws['B1'].value
0.031400000000000004
>>>
>>> ws['B1'].number_format
'0%'
Using formulae
>>> 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.

Merge / Unmerge cells

When you merge cells all cells but the top-left one are removed from the worksheet. 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)
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')
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')

Performance

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 Read-only mode 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: 2.7.1
openpyxl: 2.5.7
xlsxwriter: 1.0.9

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

Times:
    xlsxwriter            :   2.69
    xlsxwriter (optimised):   2.48
    openpyxl              :   4.59
    openpyxl (optimised)  :   3.65


Versions:
python: 3.5.6
openpyxl: 2.5.7
xlsxwriter: 1.0.9

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

Times:
    xlsxwriter            :   3.20
    xlsxwriter (optimised):   3.08
    openpyxl              :   5.54
    openpyxl (optimised)  :   3.95


Versions:
python: 3.6.6
openpyxl: 2.5.7
xlsxwriter: 1.0.9

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

Times:
    xlsxwriter            :   3.18
    xlsxwriter (optimised):   3.02
    openpyxl              :   4.28
    openpyxl (optimised)  :   3.34


Versions:
python: 3.7.0
openpyxl: 2.5.7
xlsxwriter: 1.0.9

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

Times:
    xlsxwriter            :   3.02
    xlsxwriter (optimised):   2.94
    openpyxl              :   4.11
    openpyxl (optimised)  :   3.12

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 readuces 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: 2.7.1
xlread: 1.1.0
openpyxl: 2.5.11

xlrd
    Workbook loaded 61.26s
    OptimizationData 0.18s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 0.07s
    Store days 100% 0.07s
    Total time 61.59s

openpyxl
    Workbook loaded 131.36s
    OptimizationData 4.03s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 3.46s
    Store days 100% 3.50s
    Total time 142.36s

openpyxl, read-only
    Workbook loaded 0.97s
    OptimizationData 23.39s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 21.69s
    Store days 100% 17.02s
    Total time 63.07s

openpyxl, read-only, values only
    Workbook loaded 0.94s
    OptimizationData 35.88s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 29.64s
    Store days 100% 22.53s
    Total time 89.00s


Versions:
python: 3.5.6
xlread: 1.1.0
openpyxl: 2.5.11

xlrd
    Workbook loaded 67.22s
    OptimizationData 0.25s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 0.08s
    Store days 100% 0.08s
    Total time 67.63s

openpyxl
    Workbook loaded 140.84s
    OptimizationData 4.27s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 3.67s
    Store days 100% 3.88s
    Total time 152.66s

openpyxl, read-only
    Workbook loaded 1.30s
    OptimizationData 37.25s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 26.24s
    Store days 100% 20.37s
    Total time 85.17s

openpyxl, read-only, values only
    Workbook loaded 1.29s
    OptimizationData 40.53s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 34.11s
    Store days 100% 26.61s
    Total time 102.54s


Versions:
python: 3.6.7
xlread: 1.1.0
openpyxl: 2.5.11

xlrd
    Workbook loaded 51.13s
    OptimizationData 0.24s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 0.08s
    Store days 100% 0.07s
    Total time 51.51s

openpyxl
    Workbook loaded 114.45s
    OptimizationData 3.27s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 2.70s
    Store days 100% 3.08s
    Total time 123.51s

openpyxl, read-only
    Workbook loaded 1.07s
    OptimizationData 24.99s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 20.25s
    Store days 100% 16.48s
    Total time 62.79s

openpyxl, read-only, values only
    Workbook loaded 1.10s
    OptimizationData 34.35s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 28.17s
    Store days 100% 21.69s
    Total time 85.32s


Versions:
python: 3.7.1
xlread: 1.1.0
openpyxl: 2.5.11

xlrd
    Workbook loaded 59.14s
    OptimizationData 0.24s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 0.08s
    Store days 100% 0.07s
    Total time 59.53s

openpyxl
    Workbook loaded 114.90s
    OptimizationData 3.27s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 2.78s
    Store days 100% 3.16s
    Total time 124.12s

openpyxl, read-only
    Workbook loaded 0.95s
    OptimizationData 24.66s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 19.98s
    Store days 100% 15.51s
    Total time 61.10s

openpyxl, read-only, values only
    Workbook loaded 0.92s
    OptimizationData 31.89s
    Output Model 0.00s
    >>DATA>> 0.00s
    Store days 0% 27.09s
    Store days 100% 21.85s
    Total time 81.75s

Other topics

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)

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.max_row = ws.max_column = None

Write-only mode

Here again, the regular openpyxl.worksheet.worksheet.Worksheet has been replaced by a faster alternative, the openpyxl.writer.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') 

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

>>> from openpyxl import Workbook
>>> wb = Workbook(write_only = True)
>>> ws = wb.create_sheet()
>>> from openpyxl.worksheet.write_only 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.

Inserting and deleting rows and columns, moving ranges of cells

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)

To delete the columns F:H:

>>> ws.delete_cols(6, 3)

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:

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)

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

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

..literalinclude:: pie-gradient.py

"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 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 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 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 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"

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

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 instead of only one.

>>> 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=colors.RED)
>>> a1.font = ft
>>> d4.font = ft
>>>
>>> a1.font.italic = True # is not allowed 
>>>
>>> # If you want to change the color of a Font, you need to reassign it::
>>>
>>> a1.font = Font(color=colors.RED, 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

Basic Font Colors

Colors are usually RGB or aRGB hexvalues. The colors module contains some handy constants

>>> from openpyxl.styles import Font
>>> from openpyxl.styles.colors import RED
>>> font = Font(color=RED)
>>> font = Font(color="FFBB00")

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

>>> from openpyxl.styles.colors import Color
>>> c = Color(indexed=32)
>>> c = Color(theme=6, tint=0.5)

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

Sometimes you want to format a range of cells as if they were a single object. Excel pretends that this is possible by merging cells (deleting all but the top-left cell) and then recreating them in order to apply pseudo-styles.

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook


def style_range(ws, cell_range, border=Border(), fill=None, font=None, alignment=None):
    """
    Apply styles to a range of cells as if they were a single cell.

    :param ws:  Excel worksheet instance
    :param range: An excel range to style (e.g. A1:F20)
    :param border: An openpyxl Border
    :param fill: An openpyxl PatternFill or GradientFill
    :param font: An openpyxl Font object
    """

    top = Border(top=border.top)
    left = Border(left=border.left)
    right = Border(right=border.right)
    bottom = Border(bottom=border.bottom)

    first_cell = ws[cell_range.split(":")[0]]
    if alignment:
        ws.merge_cells(cell_range)
        first_cell.alignment = alignment

    rows = ws[cell_range]
    if font:
        first_cell.font = font

    for cell in rows[0]:
        cell.border = cell.border + top
    for cell in rows[-1]:
        cell.border = cell.border + bottom

    for row in rows:
        l = row[0]
        r = row[-1]
        l.border = l.border + left
        r.border = r.border + right
        if fill:
            for c in row:
                c.fill = fill

wb = Workbook()
ws = wb.active
my_cell = ws['B2']
my_cell.value = "My Cell"
thin = Side(border_style="thin", color="000000")
double = Side(border_style="double", color="ff0000")

border = Border(top=double, left=thin, right=thin, bottom=double)
fill = PatternFill("solid", fgColor="DDDDDD")
fill = GradientFill(stop=("000000", "FFFFFF"))
font = Font(b=True, color="FF0000")
al = Alignment(horizontal="center", vertical="center")


style_range(ws, 'B2:F4', border=border, fill=fill, font=font, alignment=al)
wb.save("styled.xlsx")

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

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”

see http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.sheetproperties%28v=office.14%29.aspx_ for 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

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

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

Using filters and sorts

It’s possible to add a filter to a worksheet.

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 rearranges or format cells or rows in the range.

To add a filter you define a range and then add columns and sort conditions:

from openpyxl import Workbook

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)

ws.auto_filter.ref = "A1:B15"
ws.auto_filter.add_filter_column(0, ["Kiwi", "Apple", "Mango"])
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"

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.

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

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. They are defined globally for a workbook and accessed from there defined_names attribue.

Sample use for ranges

Accessing a range called “my_range”:

my_range = wb.defined_names['my_range']
# if this contains a range of cells then the destinations attribute is not None
dests = my_range.destinations # returns a generator of (worksheet title, cell range) tuples

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

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
ws.add_table(tab)
wb.save("table.xlsx")

By default tables are created with a header from the first row and filters for all the columns.

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

Important notes

Table names must be unique within a workbook and table headers and filter ranges must always contain strings. If this is not the case then Excel may consider the file invalid and remove the table.

Parsing Formulas

openpyxl supports limited parsing of formulas embedded in cells. The openpyxl.formula package contains a Tokenizer class to break formulas into their consitutuent 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.

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
>>> wb.protection.sheet = True
>>> wb.protection.enable()
>>> wb.protection.disabe()

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 = '...'

Information for Developers

Development

With the ongoing development of openpyxl, there is occasional information useful to assist developers.

What is suppoprted

The primary aim of openpyxl is to support reading and writing Microsoft Excel 2010 files. Where possible support for files generated by other libraries or programs is available but this is not guaranteed.

Supporting different Python versions

We have a small library of utility functions to support development for Python 2 and 3. This is openpyxl.compat for Python and openpyxl.xml for XML functions.

Coding style

Use PEP-8 except when implementing attributes for roundtripping but always use Python data conventions (boolean, None, etc.) Note exceptions in docstrings.

Getting the source

The source code is hosted on bitbucket.org. You can get it using a Mercurial client and the following URL.

$ hg clone https://bitbucket.org/openpyxl/openpyxl
$ virtualenv openpyxl
$ hg up 2.5
$ cd openpyxl
$ source bin/activate
$ pip install -U -r requirements.txt
$ python setup.py develop

Specification

The file specification for OOXML was released jointly as ECMA 376 and ISO 29500.

Testing

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

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.

Please see Testing on Windows for additional information on setting up and testing on Windows.

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. 2.5.15. 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 2.5.15, pull requests should be made to the 2.5 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.

Testing on Windows

Although openpyxl itself is pure Python and should run on any Python, we do use some libraries that require compiling for tests and documentation. The setup for testing on Windows is somewhat different.

Getting started

Once you have installed the versions of Python (2.6, 2.7, 3.3, 3.4) you should setup a development environment for testing so that you do not adversely affect the system install.

Setting up a development environment

First of all you should checkout a copy of the repository. Atlassian provides a nice GUI client SourceTree that allows you to do this with a single-click from the browser.

By default the repository will be installed under your user folder. eg. c:UsersYOURUSERopenpyxl

Switch to the branch you want to work on by double-clicking it. The default branch should never be used for development work.

Creating a virtual environment

You will need to manually install virtualenv. This is best done by first installing pip. open a command line and download the script “get_pip.py” to your preferred Python folder:

bitsadmin /transfer pip http://bootstrap.pypa.io/get-pip.py c:\python27\get-pip.py # change the path as necessary

Install pip (it needs to be at least pip 6.0):

python get_pip.py

Now you can install virtualenv:

Scripts\pip install virtualenv
Scripts\virtualenv c:\Users\YOURUSER\openpyxl

lxml

openpyxl needs lxml in order to run the tests. Unfortunately, automatic installation of lxml on Windows is tricky as pip defaults to try and compile it. This can be avoided by using pre-compiled versions of the library.

  1. In the command line switch to your repository folder:

    cd c:\Users\YOURUSER\openpyxl
    
  2. Activate the virtualenv:

    Scripts\activate
    
  3. Install a development version of openpyxl:

    pip install -e .
    
  4. Download all the relevant lxml Windows wheels

    Releases for legacy versions of Python:

  5. Move all these files to a folder called “downloads” in your openpyxl checkout

  6. Install the project requirements:

    pip download -r requirements.txt -d downloads
    pip install --no-index --find-links downloads -r requirements.txt
    

To run tests for the virtualenv:

py.test -xrf openpyxl # the flag will stop testing at the first error

tox

We use tox to run the tests on different Python versions and configurations. Using it is as simple as:

set PIP_FIND_LINKS=downloads
tox openpyxl

API Documentation

Full API

openpyxl package

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

Bases: openpyxl.styles.styleable.StyleableObject

Describes cell associated properties.

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

ERROR_CODES = ('#NULL!', '#DIV/0!', '#VALUE!', '#REF!', '#NAME?', '#NUM!', '#N/A')
TYPE_BOOL = 'b'
TYPE_ERROR = 'e'
TYPE_FORMULA = 'f'
TYPE_FORMULA_CACHE_STRING = 'str'
TYPE_INLINE = 'inlineStr'
TYPE_NULL = 'n'
TYPE_NUMERIC = 'n'
TYPE_STRING = 's'
VALID_TYPES = ('s', 'f', 'n', 'b', 'n', 'inlineStr', 'e', 'str')
base_date
check_error(value)[source]

Tries to convert Error” else N/A

check_string(value)[source]

Check string coding, length, and line break character

col_idx

Column number of this cell (1-based)

column

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

comment

Returns the comment associated with this cell

Type:openpyxl.comments.Comment
coordinate

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

data_type
encoding
guess_types

Return the hyperlink target or an empty string

internal_value

Always returns the value for excel.

is_date

True if the value is formatted as a date

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

Returns a cell location relative to this cell.

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

openpyxl.cell.Cell

parent
row

Row number of this cell (1-based)

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

Coerce values according to their explicit type

value

Get or set the value held in the cell.

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

Bases: abc.ABC

base_date
comment
coordinate
encoding
guess_types
internal_value
is_date
number_format
offset(row=0, column=0)[source]
style
value
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
base_date
border
column
coordinate
data_type
fill
font
internal_value
is_date
number_format
parent
protection
row
shared_strings
style_array
value
openpyxl.cell.text module
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 {‘singleAccounting’, ‘double’, ‘single’, ‘doubleAccounting’}

vertAlign

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

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

Bases: openpyxl.descriptors.serialisable.Serialisable

alignment

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

fontId

Values must be of type <class ‘int’>

tagname = 'phoneticPr'
type

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

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 {‘percentStacked’, ‘stacked’, ‘standard’}

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 {‘percentStacked’, ‘stacked’, ‘standard’}

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 descriptve 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 {‘b’, ‘t’, ‘l’, ‘r’}

baseTimeUnit

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

crossAx

Values must be of type <class ‘int’>

crosses

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

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 {‘cross’, ‘out’, ‘in’}

majorTimeUnit

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

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 {‘cross’, ‘out’, ‘in’}

minorTimeUnit

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

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’, ‘high’, ‘nextTo’}

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 descriptve 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 descriptve 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 descriptve 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 {‘tenMillions’, ‘thousands’, ‘hundredMillions’, ‘hundredThousands’, ‘trillions’, ‘billions’, ‘hundreds’, ‘tenThousands’, ‘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 {‘b’, ‘t’, ‘l’, ‘r’}

crossAx

Values must be of type <class ‘int’>

crossBetween

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

crosses

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

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 {‘cross’, ‘out’, ‘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 {‘cross’, ‘out’, ‘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’, ‘high’, ‘nextTo’}

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 {‘b’, ‘t’, ‘l’, ‘r’}

crossAx

Values must be of type <class ‘int’>

crosses

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

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 {‘cross’, ‘out’, ‘in’}

minorGridlines

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

minorTickMark

Value must be one of {‘cross’, ‘out’, ‘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’, ‘high’, ‘nextTo’}

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 {‘b’, ‘t’, ‘l’, ‘r’}

crossAx

Values must be of type <class ‘int’>

crosses

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

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 {‘ctr’, ‘l’, ‘r’}

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 {‘cross’, ‘out’, ‘in’}

minorGridlines

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

minorTickMark

Value must be one of {‘cross’, ‘out’, ‘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’, ‘high’, ‘nextTo’}

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 {‘bar’, ‘col’}

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’, ‘percentStacked’, ‘stacked’, ‘standard’}

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 {‘bar’, ‘col’}

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’, ‘percentStacked’, ‘stacked’, ‘standard’}

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 {‘cylinder’, ‘box’, ‘cone’, ‘pyramid’, ‘pyramidToMax’, ‘coneToMax’}

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 descriptve 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 {‘area’, ‘w’}

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
class openpyxl.chart.chartspace.ChartContainer(title=None, autoTitleDeleted=None, pivotFmts=None, 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 {‘span’, ‘zero’, ‘gap’}

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

Values must be of type <class ‘openpyxl.chart.chartspace.PivotFormatList’>

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’>

graphicalProperties

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

lang

Values must be of type <class ‘str’>

pivotSource

Values must be of type <class ‘openpyxl.chart.chartspace.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 descriptve 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.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 descriptve 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 descriptve 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 descriptve 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.chartspace.PivotFormatList(pivotFmt=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

pivotFmt

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

tagname = 'pivotFmts'
class openpyxl.chart.chartspace.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'
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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

errBarType

Value must be one of {‘both’, ‘plus’, ‘minus’}

errDir

Value must be one of {‘y’, ‘x’}

errValType

Value must be one of {‘percentage’, ‘cust’, ‘stdDev’, ‘fixedVal’, ‘stdErr’}

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 descriptve 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 descriptve 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 descriptve 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 {‘b’, ‘inEnd’, ‘r’, ‘bestFit’, ‘outEnd’, ‘inBase’, ‘t’, ‘ctr’, ‘l’}

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 {‘b’, ‘inEnd’, ‘r’, ‘bestFit’, ‘outEnd’, ‘inBase’, ‘t’, ‘ctr’, ‘l’}

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=None, hMode=None, 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 {‘factor’, ‘edge’}

height

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptve 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 {‘factor’, ‘edge’}

width

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

x

Values must be of type <class ‘float’>

xMode

Value must be one of {‘factor’, ‘edge’}

y

Values must be of type <class ‘float’>

yMode

Value must be one of {‘factor’, ‘edge’}

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 descriptve 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 {‘b’, ‘l’, ‘t’, ‘tr’, ‘r’}

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 descriptve 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 descriptve 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 {‘percentStacked’, ‘stacked’, ‘standard’}

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 {‘percentStacked’, ‘stacked’, ‘standard’}

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 descriptve 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 descriptve 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 {‘diamond’, ‘x’, ‘triangle’, ‘auto’, ‘star’, ‘circle’, ‘plus’, ‘dot’, ‘square’, ‘dash’, ‘picture’}

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 {‘stretch’, ‘stack’, ‘stackScale’}

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 descriptve name is desired (eg. “underline” for “u”)

ofPieType

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

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 {‘auto’, ‘percent’, ‘cust’, ‘pos’, ‘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 descriptve name is desired (eg. “underline” for “u”)

varyColors

Values must be of type <class ‘bool’>

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

extLst

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

radarStyle

Value must be one of {‘filled’, ‘standard’, ‘marker’}

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 descriptve 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
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

cells

Return a flattened list of all cells (by column)

cols

Return all cells in range by row

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 cells in range by column

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 descriptve name is desired (eg. “underline” for “u”)

extLst

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

scatterStyle

Value must be one of {‘smooth’, ‘lineMarker’, ‘smoothMarker’, ‘marker’, ‘line’}

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’>

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 {‘cylinder’, ‘box’, ‘cone’, ‘pyramid’, ‘pyramidToMax’, ‘coneToMax’}

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 descriptve name is desired (eg. “underline” for “u”)

to_tree(tagname=None, idx=None)[source]
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 descriptve 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 descriptve 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 {‘black’, ‘auto’, ‘white’, ‘invGray’, ‘hidden’, ‘clr’, ‘grayWhite’, ‘blackGray’, ‘gray’, ‘ltGray’, ‘blackWhite’}

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 {‘movingAvg’, ‘log’, ‘poly’, ‘linear’, ‘exp’, ‘power’}

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 descriptve 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 descriptve 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 descriptve 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’, ‘veryHidden’, ‘hidden’}

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’, ‘veryHidden’, ‘hidden’}

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 {‘sheet’, ‘chart’, ‘autoFilter’, ‘range’, ‘label’, ‘pivotTable’, ‘query’, ‘printArea’}

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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=None, 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 descriptve 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.ObjectAnchor(moveWithCells=None, sizeWithCells=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

moveWithCells

Values must be of type <class ‘bool’>

sizeWithCells

Values must be of type <class ‘bool’>

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’>

anchor

Values must be of type <class ‘openpyxl.comments.comment_sheet.ObjectAnchor’>

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 {‘left’, ‘justify’, ‘right’, ‘distributed’, ‘center’}

textVAlign

Value must be one of {‘bottom’, ‘center’, ‘distributed’, ‘top’, ‘justify’}

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

Bases: object

Submodules
openpyxl.descriptors.base module
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 descriptve 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
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
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

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.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: openpyxl.descriptors._Serialisable

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 descriptve 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 descriptve 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 {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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 {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

accent2

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

accent3

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

accent4

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

accent5

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

accent6

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

bg1

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

bg2

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

extLst

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

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

tagname = 'clrMapOvr'
tx1

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

tx2

Value must be one of {‘dk1’, ‘folHlink’, ‘dk2’, ‘accent2’, ‘lt2’, ‘hlink’, ‘accent5’, ‘accent6’, ‘accent4’, ‘lt1’, ‘accent1’, ‘accent3’}

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 {‘dk1’, ‘folHlink’, ‘bg2’, ‘tx2’, ‘phClr’, ‘accent2’, ‘dk2’, ‘lt2’, ‘hlink’, ‘tx1’, ‘accent5’, ‘bg1’, ‘accent4’, ‘accent6’, ‘lt1’, ‘accent1’, ‘accent3’}

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 {‘3dDkShadow’, ‘gradientInactiveCaption’, ‘activeCaption’, ‘hotLight’, ‘windowText’, ‘inactiveCaption’, ‘gradientActiveCaption’, ‘3dLight’, ‘inactiveBorder’, ‘highlight’, ‘infoBk’, ‘menuHighlight’, ‘window’, ‘btnText’, ‘activeBorder’, ‘highlightText’, ‘appWorkspace’, ‘menuText’, ‘windowFrame’, ‘infoText’, ‘scrollBar’, ‘captionText’, ‘grayText’, ‘btnFace’, ‘btnHighlight’, ‘menu’, ‘background’, ‘btnShadow’, ‘menuBar’, ‘inactiveCaptionText’}

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 descriptve 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 descriptve 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
get_emu_dimensions()[source]

return (x, y, w, h) in EMU

Note

Deprecated: Private method used when serialising

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 {‘tree’, ‘sib’}

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’, ‘over’, ‘screen’, ‘lighten’, ‘darken’}

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 {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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

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 {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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=None, contrast=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

bright

Values must be of type <class ‘int’>

contrast

Values must be of type <class ‘int’>

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 {‘b’, ‘r’, ‘bl’, ‘t’, ‘l’, ‘tl’, ‘ctr’, ‘tr’, ‘br’}

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 {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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 {‘shdw5’, ‘shdw2’, ‘shdw17’, ‘shdw13’, ‘shdw19’, ‘shdw12’, ‘shdw4’, ‘shdw11’, ‘shdw14’, ‘shdw15’, ‘shdw16’, ‘shdw20’, ‘shdw18’, ‘shdw6’, ‘shdw1’, ‘shdw7’, ‘shdw9’, ‘shdw10’, ‘shdw8’, ‘shdw3’}

prstClr

Value must be one of {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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 {‘b’, ‘r’, ‘bl’, ‘t’, ‘l’, ‘tl’, ‘ctr’, ‘tr’, ‘br’}

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=None, amt=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

amt

Values must be of type <class ‘int’>

hue

Values must be of type <class ‘int’>

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 {‘print’, ‘email’, ‘screen’, ‘hqprint’}

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: b=None, r=None, t=None, l=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 {‘y’, ‘xy’, ‘x’}

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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 {‘shape’, ‘circle’, ‘rect’}

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 descriptve 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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

prst

Value must be one of {‘wdUpDiag’, ‘dashUpDiag’, ‘solidDmnd’, ‘shingle’, ‘smGrid’, ‘horz’, ‘dashDnDiag’, ‘plaid’, ‘dkVert’, ‘pct75’, ‘dkDnDiag’, ‘smCheck’, ‘wave’, ‘smConfetti’, ‘ltVert’, ‘dashHorz’, ‘trellis’, ‘cross’, ‘lgCheck’, ‘horzBrick’, ‘lgGrid’, ‘dnDiag’, ‘diagCross’, ‘pct25’, ‘dashVert’, ‘ltDnDiag’, ‘sphere’, ‘pct40’, ‘pct50’, ‘vert’, ‘dkHorz’, ‘dkUpDiag’, ‘wdDnDiag’, ‘zigZag’, ‘diagBrick’, ‘pct20’, ‘pct10’, ‘openDmnd’, ‘pct90’, ‘weave’, ‘ltUpDiag’, ‘pct60’, ‘narVert’, ‘dotGrid’, ‘pct5’, ‘upDiag’, ‘pct30’, ‘lgConfetti’, ‘divot’, ‘narHorz’, ‘dotDmnd’, ‘ltHorz’, ‘pct70’, ‘pct80’}

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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

hslClr

Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>

prstClr

Value must be one of {‘dkKhaki’, ‘darkSeaGreen’, ‘dkGrey’, ‘ivory’, ‘grey’, ‘darkKhaki’, ‘aquamarine’, ‘medSlateBlue’, ‘blanchedAlmond’, ‘mediumBlue’, ‘floralWhite’, ‘indianRed’, ‘ltGrey’, ‘pink’, ‘dkGreen’, ‘dkCyan’, ‘ltPink’, ‘mediumPurple’, ‘papayaWhip’, ‘navajoWhite’, ‘seaGreen’, ‘mediumTurquoise’, ‘lightYellow’, ‘midnightBlue’, ‘silver’, ‘cadetBlue’, ‘brown’, ‘medVioletRed’, ‘red’, ‘thistle’, ‘dkSalmon’, ‘lightSkyBlue’, ‘medOrchid’, ‘yellow’, ‘cornsilk’, ‘lavender’, ‘turquoise’, ‘darkCyan’, ‘dimGrey’, ‘mediumSlateBlue’, ‘dkOrange’, ‘azure’, ‘darkViolet’, ‘wheat’, ‘skyBlue’, ‘lightGrey’, ‘green’, ‘lightGoldenrodYellow’, ‘firebrick’, ‘dkSeaGreen’, ‘oliveDrab’, ‘whiteSmoke’, ‘orchid’, ‘maroon’, ‘khaki’, ‘ltSkyBlue’, ‘darkBlue’, ‘lawnGreen’, ‘paleGreen’, ‘seaShell’, ‘hotPink’, ‘purple’, ‘dkRed’, ‘sienna’, ‘white’, ‘dodgerBlue’, ‘lightSalmon’, ‘dkMagenta’, ‘lemonChiffon’, ‘springGreen’, ‘plum’, ‘lavenderBlush’, ‘black’, ‘paleGoldenrod’, ‘darkMagenta’, ‘lightSteelBlue’, ‘mediumSeaGreen’, ‘greenYellow’, ‘medBlue’, ‘forestGreen’, ‘lightCoral’, ‘ltCyan’, ‘darkSlateBlue’, ‘mediumAquamarine’, ‘lightBlue’, ‘lightSeaGreen’, ‘powderBlue’, ‘ltGray’, ‘coral’, ‘chocolate’, ‘lightGreen’, ‘dkOrchid’, ‘burlyWood’, ‘lime’, ‘cyan’, ‘mediumSpringGreen’, ‘mistyRose’, ‘ghostWhite’, ‘oldLace’, ‘lightSlateGray’, ‘teal’, ‘ltSteelBlue’, ‘lightGray’, ‘yellowGreen’, ‘indigo’, ‘darkTurquoise’, ‘orangeRed’, ‘dkGray’, ‘slateBlue’, ‘sandyBrown’, ‘darkOrange’, ‘antiqueWhite’, ‘dkGoldenrod’, ‘gray’, ‘slateGray’, ‘dkBlue’, ‘goldenrod’, ‘peru’, ‘darkGoldenrod’, ‘darkSlateGrey’, ‘snow’, ‘gainsboro’, ‘violet’, ‘rosyBrown’, ‘aqua’, ‘ltSalmon’, ‘darkGray’, ‘mediumOrchid’, ‘paleTurquoise’, ‘mintCream’, ‘cornflowerBlue’, ‘slateGrey’, ‘dkViolet’, ‘ltYellow’, ‘bisque’, ‘ltSlateGrey’, ‘darkSalmon’, ‘blueViolet’, ‘fuchsia’, ‘navy’, ‘deepPink’, ‘tan’, ‘honeydew’, ‘darkGreen’, ‘lightSlateGrey’, ‘crimson’, ‘salmon’, ‘ltBlue’, ‘steelBlue’, ‘dkTurquoise’, ‘dkSlateBlue’, ‘medSpringGreen’, ‘darkOliveGreen’, ‘dkOliveGreen’, ‘darkGrey’, ‘ltCoral’, ‘orange’, ‘blue’, ‘medTurquoise’, ‘ltGoldenrodYellow’, ‘mediumVioletRed’, ‘moccasin’, ‘medSeaGreen’, ‘medPurple’, ‘limeGreen’, ‘peachPuff’, ‘aliceBlue’, ‘medAquamarine’, ‘olive’, ‘darkRed’, ‘ltSeaGreen’, ‘saddleBrown’, ‘lightCyan’, ‘tomato’, ‘ltGreen’, ‘ltSlateGray’, ‘chartreuse’, ‘paleVioletRed’, ‘beige’, ‘magenta’, ‘lightPink’, ‘dimGray’, ‘gold’, ‘dkSlateGrey’, ‘royalBlue’, ‘deepSkyBlue’, ‘darkSlateGray’, ‘darkOrchid’, ‘dkSlateGray’, ‘linen’}

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: b=None, r=None, t=None, l=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 {‘b’, ‘r’, ‘bl’, ‘t’, ‘l’, ‘tl’, ‘ctr’, ‘tr’, ‘br’}

flip

Value must be one of {‘y’, ‘xy’, ‘x’}

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 {‘coolSlant’, ‘artDeco’, ‘relaxedInset’, ‘hardEdge’, ‘softRound’, ‘angle’, ‘cross’, ‘slope’, ‘riblet’, ‘circle’, ‘divot’, ‘convex’}

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 {‘legacyObliqueTop’, ‘isometricOffAxis1Right’, ‘obliqueTop’, ‘perspectiveLeft’, ‘obliqueLeft’, ‘isometricRightDown’, ‘isometricOffAxis3Right’, ‘obliqueTopLeft’, ‘legacyObliqueTopLeft’, ‘isometricTopDown’, ‘obliqueBottomLeft’, ‘legacyObliqueBottom’, ‘obliqueRight’, ‘perspectiveRight’, ‘isometricLeftDown’, ‘perspectiveHeroicExtremeRightFacing’, ‘isometricOffAxis4Left’, ‘legacyPerspectiveTop’, ‘perspectiveRelaxed’, ‘legacyPerspectiveBottomRight’, ‘isometricOffAxis1Left’, ‘legacyPerspectiveBottom’, ‘perspectiveAbove’, ‘perspectiveAboveRightFacing’, ‘perspectiveHeroicRightFacing’, ‘legacyPerspectiveLeft’, ‘perspectiveBelow’, ‘isometricOffAxis1Top’, ‘legacyObliqueFront’, ‘legacyObliqueBottomLeft’, ‘isometricOffAxis2Top’, ‘obliqueBottom’, ‘obliqueBottomRight’, ‘isometricOffAxis4Right’, ‘isometricTopUp’, ‘isometricBottomUp’, ‘legacyPerspectiveRight’, ‘isometricRightUp’, ‘legacyObliqueTopRight’, ‘legacyPerspectiveFront’, ‘isometricOffAxis3Left’, ‘perspectiveContrastingLeftFacing’, ‘legacyObliqueLeft’, ‘obliqueTopRight’, ‘isometricOffAxis3Bottom’, ‘legacyPerspectiveTopLeft’, ‘perspectiveHeroicLeftFacing’, ‘legacyPerspectiveTopRight’, ‘isometricBottomDown’, ‘isometricOffAxis2Left’, ‘perspectiveFront’, ‘perspectiveAboveLeftFacing’, ‘perspectiveHeroicExtremeLeftFacing’, ‘legacyObliqueRight’, ‘legacyPerspectiveBottomLeft’, ‘isometricOffAxis4Bottom’, ‘perspectiveRelaxedModerately’, ‘isometricLeftUp’, ‘perspectiveContrastingRightFacing’, ‘isometricOffAxis2Right’, ‘orthographicFront’, ‘legacyObliqueBottomRight’}

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’>

rect

Values must be of type <class ‘openpyxl.drawing.geometry.GeomRect’>

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 {‘b’, ‘r’, ‘bl’, ‘t’, ‘l’, ‘tl’, ‘tr’, ‘br’}

rig

Value must be one of {‘twoPt’, ‘legacyNormal3’, ‘chilly’, ‘legacyNormal4’, ‘contrasting’, ‘sunset’, ‘legacyFlat2’, ‘legacyNormal1’, ‘glow’, ‘threePt’, ‘flood’, ‘legacyFlat1’, ‘balanced’, ‘sunrise’, ‘legacyNormal2’, ‘legacyFlat4’, ‘brightRoom’, ‘flat’, ‘legacyHarsh1’, ‘legacyHarsh3’, ‘legacyHarsh4’, ‘harsh’, ‘morning’, ‘legacyHarsh2’, ‘soft’, ‘freezing’, ‘legacyFlat3’}

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’, ‘lighten’, ‘norm’, ‘darken’, ‘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 descriptve 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 descriptve 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 {‘wedgeRectCallout’, ‘hexagon’, ‘flowChartDisplay’, ‘doubleWave’, ‘chord’, ‘flowChartManualOperation’, ‘cube’, ‘bracePair’, ‘wedgeRoundRectCallout’, ‘stripedRightArrow’, ‘flowChartConnector’, ‘star12’, ‘sun’, ‘teardrop’, ‘gear9’, ‘rightArrowCallout’, ‘corner’, ‘leftBrace’, ‘bentConnector2’, ‘leftBracket’, ‘flowChartPreparation’, ‘quadArrow’, ‘swooshArrow’, ‘flowChartMultidocument’, ‘lightningBolt’, ‘upArrow’, ‘accentCallout2’, ‘flowChartOr’, ‘curvedConnector4’, ‘blockArc’, ‘borderCallout1’, ‘leftRightCircularArrow’, ‘plaque’, ‘halfFrame’, ‘flowChartInternalStorage’, ‘curvedConnector2’, ‘leftRightArrowCallout’, ‘mathNotEqual’, ‘flowChartMagneticTape’, ‘quadArrowCallout’, ‘mathPlus’, ‘bracketPair’, ‘actionButtonSound’, ‘wedgeEllipseCallout’, ‘callout2’, ‘curvedLeftArrow’, ‘heptagon’, ‘actionButtonBlank’, ‘lineInv’, ‘curvedRightArrow’, ‘curvedDownArrow’, ‘arc’, ‘curvedConnector3’, ‘snip2DiagRect’, ‘flowChartMagneticDrum’, ‘plaqueTabs’, ‘mathEqual’, ‘donut’, ‘curvedUpArrow’, ‘star7’, ‘flowChartDocument’, ‘chartX’, ‘accentBorderCallout3’, ‘mathMultiply’, ‘gear6’, ‘frame’, ‘accentCallout3’, ‘octagon’, ‘round2SameRect’, ‘circularArrow’, ‘noSmoking’, ‘flowChartSort’, ‘bentArrow’, ‘ellipseRibbon’, ‘pentagon’, ‘leftCircularArrow’, ‘parallelogram’, ‘bentConnector5’, ‘mathDivide’, ‘heart’, ‘upDownArrow’, ‘callout1’, ‘notchedRightArrow’, ‘irregularSeal2’, ‘leftArrow’, ‘ribbon2’, ‘flowChartOnlineStorage’, ‘rightArrow’, ‘moon’, ‘bentUpArrow’, ‘squareTabs’, ‘curvedConnector5’, ‘star6’, ‘round2DiagRect’, ‘homePlate’, ‘actionButtonHelp’, ‘funnel’, ‘leftRightUpArrow’, ‘flowChartInputOutput’, ‘actionButtonEnd’, ‘flowChartCollate’, ‘snipRoundRect’, ‘bentConnector3’, ‘foldedCorner’, ‘pieWedge’, ‘plus’, ‘snip2SameRect’, ‘borderCallout2’, ‘ribbon’, ‘ellipseRibbon2’, ‘diagStripe’, ‘flowChartMagneticDisk’, ‘can’, ‘star4’, ‘flowChartPredefinedProcess’, ‘flowChartDelay’, ‘star5’, ‘actionButtonMovie’, ‘nonIsoscelesTrapezoid’, ‘rtTriangle’, ‘dodecagon’, ‘flowChartProcess’, ‘uturnArrow’, ‘bentConnector4’, ‘actionButtonInformation’, ‘actionButtonDocument’, ‘actionButtonBackPrevious’, ‘leftArrowCallout’, ‘flowChartSummingJunction’, ‘triangle’, ‘actionButtonForwardNext’, ‘flowChartOffpageConnector’, ‘flowChartPunchedCard’, ‘ellipse’, ‘flowChartTerminator’, ‘flowChartPunchedTape’, ‘callout3’, ‘bevel’, ‘round1Rect’, ‘accentBorderCallout1’, ‘trapezoid’, ‘rect’, ‘leftRightRibbon’, ‘flowChartDecision’, ‘accentBorderCallout2’, ‘upDownArrowCallout’, ‘cloud’, ‘actionButtonReturn’, ‘flowChartMerge’, ‘flowChartExtract’, ‘horizontalScroll’, ‘wave’, ‘irregularSeal1’, ‘borderCallout3’, ‘pie’, ‘diamond’, ‘chevron’, ‘flowChartAlternateProcess’, ‘cornerTabs’, ‘verticalScroll’, ‘roundRect’, ‘line’, ‘chartStar’, ‘leftUpArrow’, ‘smileyFace’, ‘rightBracket’, ‘flowChartManualInput’, ‘star16’, ‘snip1Rect’, ‘star10’, ‘accentCallout1’, ‘star32’, ‘decagon’, ‘mathMinus’, ‘downArrowCallout’, ‘actionButtonBeginning’, ‘downArrow’, ‘actionButtonHome’, ‘star8’, ‘cloudCallout’, ‘straightConnector1’, ‘upArrowCallout’, ‘flowChartOfflineStorage’, ‘chartPlus’, ‘leftRightArrow’, ‘star24’, ‘rightBrace’}

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 {‘flat’, ‘legacyWireframe’, ‘legacyPlastic’, ‘legacyMetal’, ‘plastic’, ‘softmetal’, ‘dkEdge’, ‘clear’, ‘softEdge’, ‘legacyMatte’, ‘metal’, ‘matte’, ‘warmMatte’, ‘powder’, ‘translucentPowder’}

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 descriptve 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 descriptve 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.image.bounding_box(bw, bh, w, h)[source]

Returns a tuple (new_width, new_height) which has the property that it fits within box_width and box_height and has (close to) the same aspect ratio as the original size

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 descriptve 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 descriptve 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’, ‘med’, ‘sm’}

namespace = 'http://schemas.openxmlformats.org/drawingml/2006/main'
tagname = 'end'
type

Value must be one of {‘stealth’, ‘diamond’, ‘arrow’, ‘triangle’, ‘oval’, ‘none’}

w

Value must be one of {‘lg’, ‘med’, ‘sm’}

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 {‘in’, ‘ctr’}

bevel

Values must be of type <class ‘bool’>

cap

Value must be one of {‘flat’, ‘rnd’, ‘sq’}

cmpd

Value must be one of {‘thickThin’, ‘sng’, ‘thinThick’, ‘tri’, ‘dbl’}

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 descriptve 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’, ‘lgDash’, ‘dashDot’, ‘sysDashDotDot’, ‘dot’, ‘solid’, ‘dash’, ‘sysDash’, ‘sysDot’, ‘sysDashDot’, ‘lgDashDot’}

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 descriptve 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 descriptve 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 {‘black’, ‘auto’, ‘white’, ‘invGray’, ‘hidden’, ‘clr’, ‘grayWhite’, ‘blackGray’, ‘gray’, ‘ltGray’, ‘blackWhite’}

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.shape module
class openpyxl.drawing.shape.Shape(chart, coordinates=((0, 0), (1, 1)), text=None, scheme='accent1')[source]

Bases: object

a drawing inside a chart coordiantes are specified by the user in the axis units

FONT_HEIGHT = 8
FONT_WIDTH = 7
MARGIN_BOTTOM = 28
MARGIN_LEFT = 20
RECT = 'rect'

“line” “lineInv” “triangle” “rtTriangle” “diamond” “parallelogram” “trapezoid” “nonIsoscelesTrapezoid” “pentagon” “hexagon” “heptagon” “octagon” “decagon” “dodecagon” “star4” “star5” “star6” “star7” “star8” “star10” “star12” “star16” “star24” “star32” “roundRect” “round1Rect” “round2SameRect” “round2DiagRect” “snipRoundRect” “snip1Rect” “snip2SameRect” “snip2DiagRect” “plaque” “ellipse” “teardrop” “homePlate” “chevron” “pieWedge” “pie” “blockArc” “donut” “noSmoking” “rightArrow” “leftArrow” “upArrow” “downArrow” “stripedRightArrow” “notchedRightArrow” “bentUpArrow” “leftRightArrow” “upDownArrow” “leftUpArrow” “leftRightUpArrow” “quadArrow” “leftArrowCallout” “rightArrowCallout” “upArrowCallout” “downArrowCallout” “leftRightArrowCallout” “upDownArrowCallout” “quadArrowCallout” “bentArrow” “uturnArrow” “circularArrow” “leftCircularArrow” “leftRightCircularArrow” “curvedRightArrow” “curvedLeftArrow” “curvedUpArrow” “curvedDownArrow” “swooshArrow” “cube” “can” “lightningBolt” “heart” “sun” “moon” “smileyFace” “irregularSeal1” “irregularSeal2” “foldedCorner” “bevel” “frame” “halfFrame” “corner” “diagStripe” “chord” “arc” “leftBracket” “rightBracket” “leftBrace” “rightBrace” “bracketPair” “bracePair” “straightConnector1” “bentConnector2” “bentConnector3” “bentConnector4” “bentConnector5” “curvedConnector2” “curvedConnector3” “curvedConnector4” “curvedConnector5” “callout1” “callout2” “callout3” “accentCallout1” “accentCallout2” “accentCallout3” “borderCallout1” “borderCallout2” “borderCallout3” “accentBorderCallout1” “accentBorderCallout2” “accentBorderCallout3” “wedgeRectCallout” “wedgeRoundRectCallout” “wedgeEllipseCallout” “cloudCallout” “cloud” “ribbon” “ribbon2” “ellipseRibbon” “ellipseRibbon2” “leftRightRibbon” “verticalScroll” “horizontalScroll” “wave” “doubleWave” “plus” “flowChartProcess” “flowChartDecision” “flowChartInputOutput” “flowChartPredefinedProcess” “flowChartInternalStorage” “flowChartDocument” “flowChartMultidocument” “flowChartTerminator” “flowChartPreparation” “flowChartManualInput” “flowChartManualOperation” “flowChartConnector” “flowChartPunchedCard” “flowChartPunchedTape” “flowChartSummingJunction” “flowChartOr” “flowChartCollate” “flowChartSort” “flowChartExtract” “flowChartMerge” “flowChartOfflineStorage” “flowChartOnlineStorage” “flowChartMagneticTape” “flowChartMagneticDisk” “flowChartMagneticDrum” “flowChartDisplay” “flowChartDelay” “flowChartAlternateProcess” “flowChartOffpageConnector” “actionButtonBlank” “actionButtonHome” “actionButtonHelp” “actionButtonInformation” “actionButtonForwardNext” “actionButtonBackPrevious” “actionButtonEnd” “actionButtonBeginning” “actionButtonReturn” “actionButtonDocument” “actionButtonSound” “actionButtonMovie” “gear6” “gear9” “funnel” “mathPlus” “mathMinus” “mathMultiply” “mathDivide” “mathEqual” “mathNotEqual” “cornerTabs” “squareTabs” “plaqueTabs” “chartX” “chartStar” “chartPlus”

ROUND_RECT = 'roundRect'
border_color
border_width
color
coordinates

Return coordindates in axis units

text_color
class openpyxl.drawing.shape.ShapeWriter(shapes)[source]

Bases: object

one file per shape

write(shape_id)[source]
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’, ‘twoCell’, ‘oneCell’}

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 {‘ea1ChsPeriod’, ‘romanUcPeriod’, ‘alphaUcPeriod’, ‘thaiNumPeriod’, ‘arabic1Minus’, ‘arabicPeriod’, ‘alphaLcPeriod’, ‘thaiNumParenR’, ‘romanLcParenBoth’, ‘romanLcPeriod’, ‘arabicParenBoth’, ‘alphaUcParenBoth’, ‘romanLcParenR’, ‘arabicDbPlain’, ‘hindiAlpha1Period’, ‘thaiAlphaParenBoth’, ‘thaiAlphaPeriod’, ‘arabicParenR’, ‘hindiNumPeriod’, ‘ea1ChtPeriod’, ‘hebrew2Minus’, ‘circleNumWdBlackPlain’, ‘circleNumWdWhitePlain’, ‘ea1ChsPlain’, ‘romanUcParenBoth’, ‘thaiNumParenBoth’, ‘ea1ChtPlain’, ‘arabic2Minus’, ‘circleNumDbPlain’, ‘alphaUcParenR’, ‘arabicDbPeriod’, ‘ea1JpnKorPlain’, ‘arabicPlain’, ‘romanUcParenR’, ‘hindiNumParenR’, ‘alphaLcParenBoth’, ‘hindiAlphaPeriod’, ‘alphaLcParenR’, ‘ea1JpnChsDbPeriod’, ‘thaiAlphaParenR’, ‘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 {‘all’, ‘small’}

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 {‘sngStrike’, ‘noStrike’, ‘dblStrike’}

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 {‘wavyHeavy’, ‘dotted’, ‘dotDashHeavy’, ‘words’, ‘dashHeavy’, ‘dashLongHeavy’, ‘dashLong’, ‘sng’, ‘dbl’, ‘dotDotDashHeavy’, ‘dotDash’, ‘dotDotDash’, ‘heavy’, ‘wavyDbl’, ‘dottedHeavy’, ‘wavy’, ‘dash’}

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 descriptve 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 descriptve 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 {‘dist’, ‘r’, ‘thaiDist’, ‘justLow’, ‘just’, ‘ctr’, ‘l’}

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 ‘openpyxl.descriptors.base.Integer’>

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 {‘b’, ‘auto’, ‘ctr’, ‘t’, ‘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 0x7fbdb3067048>

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 descriptve 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 descriptve 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 {‘b’, ‘just’, ‘ctr’, ‘t’, ‘dist’}

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 {‘vert270’, ‘wordArtVert’, ‘eaVert’, ‘vert’, ‘horz’, ‘wordArtVertRtl’, ‘mongolianVert’}

vertOverflow

Value must be one of {‘overflow’, ‘ellipsis’, ‘clip’}

wrap

Value must be one of {‘none’, ‘square’}

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 0x7fbdb305ce48>

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
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 descriptve 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 descriptve 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 {‘percentile’, ‘min’, ‘max’, ‘formula’, ‘num’, ‘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 {‘4Rating’, ‘4Arrows’, ‘4TrafficLights’, ‘4RedToBlack’, ‘3Symbols’, ‘5Rating’, ‘4ArrowsGray’, ‘3TrafficLights1’, ‘3Signs’, ‘3TrafficLights2’, ‘3ArrowsGray’, ‘3Symbols2’, ‘5Arrows’, ‘5Quarters’, ‘3Arrows’, ‘3Flags’, ‘5ArrowsGray’}

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 {‘endsWith’, ‘lessThan’, ‘notContains’, ‘notEqual’, ‘notBetween’, ‘greaterThan’, ‘containsText’, ‘beginsWith’, ‘lessThanOrEqual’, ‘greaterThanOrEqual’, ‘equal’, ‘between’}

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 {‘today’, ‘lastWeek’, ‘thisWeek’, ‘last7Days’, ‘lastMonth’, ‘yesterday’, ‘nextWeek’, ‘tomorrow’, ‘nextMonth’, ‘thisMonth’}

type

Value must be one of {‘containsErrors’, ‘cellIs’, ‘endsWith’, ‘iconSet’, ‘containsBlanks’, ‘top10’, ‘aboveAverage’, ‘dataBar’, ‘containsText’, ‘notContainsBlanks’, ‘timePeriod’, ‘beginsWith’, ‘duplicateValues’, ‘uniqueValues’, ‘notContainsErrors’, ‘colorScale’, ‘expression’, ‘notContainsText’}

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 attribue 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=datetime.datetime(2019, 2, 4, 10, 20, 22, 320516), creator='openpyxl', description=None, identifier=None, language=None, modified=datetime.datetime(2019, 2, 4, 10, 20, 22, 320539), 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 descriptve 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.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
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 descriptve 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 descriptve 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.WorkbookParser(archive, workbook_part_name)[source]

Bases: object

assign_names()[source]

Bind reserved names to parsed worksheets

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.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 {‘scenario’, ‘worksheet’, ‘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 {‘ascendingNatural’, ‘descending’, ‘descendingNatural’, ‘ascending’, ‘ascendingAlpha’, ‘descendingAlpha’}

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=<class '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 {‘months’, ‘quarters’, ‘hours’, ‘range’, ‘minutes’, ‘days’, ‘seconds’, ‘years’}

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

format

Values must be of type <class ‘str’>

tagname = 'serverFormat'
class openpyxl.pivot.cache.ServerFormats(count=None, serverFormat=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

count

Values must be of type <class ‘int’>

serverFormat

Values must be of type <class ‘openpyxl.pivot.cache.ServerFormat’>

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.ServerFormats’>

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=None, 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 {‘row’, ‘column’, ‘all’}

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 {‘percentOfRow’, ‘difference’, ‘index’, ‘percentOfCol’, ‘percentOfTotal’, ‘percentDiff’, ‘runTotal’, ‘percent’, ‘normal’}

subtotal

Value must be one of {‘count’, ‘min’, ‘product’, ‘max’, ‘stdDev’, ‘sum’, ‘var’, ‘stdDevp’, ‘countNums’, ‘varp’, ‘average’}

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 {‘sum’, ‘min’, ‘max’, ‘product’, ‘count’, ‘stdDev’, ‘var’, ‘varP’, ‘countA’, ‘data’, ‘stdDevP’, ‘grand’, ‘default’, ‘avg’, ‘blank’}

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 {‘formula’, ‘formatting’, ‘blank’, ‘drill’}

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 {‘axisCol’, ‘axisPage’, ‘axisValues’, ‘axisRow’}

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 {‘button’, ‘all’, ‘topRight’, ‘data’, ‘topEnd’, ‘normal’, ‘origin’}

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 {‘axisCol’, ‘axisPage’, ‘axisValues’, ‘axisRow’}

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 {‘count’, ‘captionBeginsWith’, ‘valueLessThanOrEqual’, ‘dateNotBetween’, ‘nextYear’, ‘valueGreaterThanOrEqual’, ‘captionNotBeginsWith’, ‘captionNotEndsWith’, ‘dateNotEqual’, ‘yesterday’, ‘lastYear’, ‘captionLessThan’, ‘dateNewerThanOrEqual’, ‘thisMonth’, ‘thisYear’, ‘yearToDate’, ‘Q1’, ‘captionNotContains’, ‘dateNewerThan’, ‘dateOlderThan’, ‘lastMonth’, ‘nextQuarter’, ‘M11’, ‘dateEqual’, ‘captionBetween’, ‘nextWeek’, ‘captionNotBetween’, ‘M7’, ‘captionNotEqual’, ‘captionLessThanOrEqual’, ‘M9’, ‘M2’, ‘captionContains’, ‘sum’, ‘today’, ‘Q3’, ‘lastWeek’, ‘captionEqual’, ‘M5’, ‘thisWeek’, ‘M3’, ‘M6’, ‘M4’, ‘Q2’, ‘valueGreaterThan’, ‘valueNotEqual’, ‘captionGreaterThanOrEqual’, ‘captionEndsWith’, ‘percent’, ‘dateBetween’, ‘M8’, ‘captionGreaterThan’, ‘valueNotBetween’, ‘valueBetween’, ‘thisQuarter’, ‘unknown’, ‘dateOlderThanOrEqual’, ‘M1’, ‘tomorrow’, ‘Q4’, ‘valueEqual’, ‘valueLessThan’, ‘lastQuarter’, ‘M12’, ‘nextMonth’, ‘M10’}

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=None, 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

Values must be of type <class ‘int’>

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=None)[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 {‘sum’, ‘min’, ‘max’, ‘product’, ‘count’, ‘stdDev’, ‘var’, ‘varP’, ‘countA’, ‘data’, ‘stdDevP’, ‘grand’, ‘default’, ‘avg’, ‘blank’}

tagname = 'i'
x

Values must be of type <class ‘int’>

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=(), 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

Wrap a sequence in an containing object

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

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’>

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

Ingore errors due to unsupported parts of DrawingML

openpyxl.reader.excel module
openpyxl.reader.excel.load_workbook(filename, read_only=False, keep_vba=False, data_only=False, guess_types=False, keep_links=True)[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) – preseve vba content (this does NOT mean you can use it)
  • guess_types (bool) – guess cell content type and do not read it from the file
  • 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
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_string_table(xml_source)[source]

Read in all shared strings in the table

openpyxl.reader.worksheet module
class openpyxl.reader.worksheet.WorkSheetParser(ws, xml_source, shared_strings)[source]

Bases: object

CELL_TAG = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}c'
FORMULA_TAG = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}f'
INLINE_STRING = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}is'
MERGE_TAG = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}mergeCell'
VALUE_TAG = '{http://schemas.openxmlformats.org/spreadsheetml/2006/main}v'
parse()[source]
parse_cell(element)[source]
parse_column_dimensions(col)[source]
parse_extensions(element)[source]
parse_legacy_drawing(element)[source]
parse_merge(element)[source]
parse_row(row)[source]
parse_sheet_protection(element)[source]
parse_tables(element)[source]
parser_conditional_formatting(element)[source]
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 {‘general’, ‘left’, ‘centerContinuous’, ‘distributed’, ‘center’, ‘justify’, ‘right’, ‘fill’}

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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

vertical

Value must be one of {‘bottom’, ‘center’, ‘distributed’, ‘top’, ‘justify’}

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 descriptve name is desired (eg. “underline” for “u”)

openpyxl.styles.borders module
class openpyxl.styles.borders.Border(left=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, right=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, top=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, bottom=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, diagonal=<openpyxl.styles.borders.Side object> Parameters: style=None, color=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 descriptve name is desired (eg. “underline” for “u”)

color

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

style

Value must be one of {‘dashDot’, ‘mediumDashed’, ‘thick’, ‘dashDotDot’, ‘dotted’, ‘medium’, ‘slantDashDot’, ‘hair’, ‘mediumDashDotDot’, ‘dashed’, ‘thin’, ‘double’, ‘mediumDashDot’}

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=None, mruColors=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

index
indexedColors

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

mruColors

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

class openpyxl.styles.colors.IndexedColorList(rgbColor=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

rgbColor

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

class openpyxl.styles.colors.MRUColorList(color=None)[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

color

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

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
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=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

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

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 descriptve 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 descriptve 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 {‘linear’, ‘path’}

class openpyxl.styles.fills.PatternFill(patternType=None, fgColor=<openpyxl.styles.colors.Color object> Parameters: theme=None, auto=None, rgb='00000000', indexed=None, tint=0.0, type='rgb', bgColor=<openpyxl.styles.colors.Color object> Parameters: theme=None, auto=None, rgb='00000000', indexed=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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

patternType

Value must be one of {‘darkGrid’, ‘gray125’, ‘lightHorizontal’, ‘lightTrellis’, ‘darkVertical’, ‘mediumGray’, ‘darkHorizontal’, ‘darkDown’, ‘lightGray’, ‘lightVertical’, ‘solid’, ‘darkUp’, ‘darkTrellis’, ‘gray0625’, ‘lightUp’, ‘lightDown’, ‘lightGrid’, ‘darkGray’}

start_color

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

sz

Values must be of type <class ‘float’>

tagname = 'font'
u

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

underline

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

vertAlign

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

openpyxl.styles.named_styles module
class openpyxl.styles.named_styles.NamedStyle(name='Normal', font=<openpyxl.styles.fonts.Font object> Parameters: name=None, charset=None, family=None, b=False, i=False, strike=None, outline=None, shadow=None, condense=None, color=None, extend=None, sz=None, u=None, vertAlign=None, scheme=None, fill=<openpyxl.styles.fills.PatternFill object> Parameters: patternType=None, fgColor=<openpyxl.styles.colors.Color object> Parameters: theme=None, auto=None, rgb='00000000', indexed=None, tint=0.0, type='rgb', bgColor=<openpyxl.styles.colors.Color object> Parameters: theme=None, auto=None, rgb='00000000', indexed=None, tint=0.0, type='rgb', border=<openpyxl.styles.borders.Border object> Parameters: diagonalDown=False, outline=True, diagonalUp=False, start=None, end=None, left=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, right=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, top=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, bottom=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, diagonal=<openpyxl.styles.borders.Side object> Parameters: style=None, color=None, vertical=None, horizontal=None, alignment=<openpyxl.styles.alignment.Alignment object> Parameters: justifyLastLine=None, indent=0.0, horizontal=None, readingOrder=0.0, vertical=None, shrinkToFit=None, relativeIndent=0.0, wrapText=None, textRotation=0, number_format=None, protection=<openpyxl.styles.protection.Protection object> Parameters: locked=True, hidden=False, 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(object) → None -- append object to end[source]
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.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=None)[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

Values must be of type <class ‘openpyxl.styles.table.TableStyleElement’>

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 {‘thirdSubtotalRow’, ‘secondColumnStripe’, ‘lastColumn’, ‘headerRow’, ‘lastTotalCell’, ‘firstHeaderCell’, ‘secondRowSubheading’, ‘firstSubtotalColumn’, ‘secondColumnSubheading’, ‘pageFieldValues’, ‘firstRowStripe’, ‘wholeTable’, ‘firstSubtotalRow’, ‘thirdSubtotalColumn’, ‘secondSubtotalRow’, ‘secondSubtotalColumn’, ‘secondRowStripe’, ‘firstColumnStripe’, ‘firstRowSubheading’, ‘blankRow’, ‘pageFieldLabels’, ‘firstColumn’, ‘thirdColumnSubheading’, ‘firstColumnSubheading’, ‘firstTotalCell’, ‘lastHeaderCell’, ‘thirdRowSubheading’, ‘totalRow’}

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
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, colum) 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_levels(levels, labels)[source]

Multiindexes need expanding so that subtitles repeat

openpyxl.utils.datetime module
class openpyxl.utils.datetime.GMT[source]

Bases: datetime.tzinfo

dst(dt)[source]

datetime -> DST offset in minutes east of UTC.

tzname(dt)[source]

datetime -> string name of time zone.

utcoffset(dt)[source]

datetime -> timedelta showing offset from UTC, negative values indicating West of UTC

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

openpyxl.utils.datetime.from_excel(value, offset=2415018.5)[source]
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, offset=2415018.5)[source]
openpyxl.utils.escape module
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
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(object) → None -- append object to end[source]
index(value[, start[, stop]]) → integer -- return first index of value.[source]

Raises ValueError if the value is not present.

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 integert 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 descriptve 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.DefinedNameList(definedName=())[source]

Bases: openpyxl.descriptors.serialisable.Serialisable

append(defn)[source]
definedName

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

delete(name, scope=None)[source]

Delete a name assigned to a specific or global

get(name, scope=None)[source]

Get the name assigned to a specicic sheet or global

localnames(scope)[source]

Provide a list of all names for a particular worksheet

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.parser module
class openpyxl.workbook.parser.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’, ‘veryHidden’, ‘hidden’}

tagname = 'sheet'
class openpyxl.workbook.parser.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.workbook.parser.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.workbook.parser.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.workbook.parser.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 descriptve 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.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’, ‘autoNoTable’, ‘manual’}

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 {‘R1C1’, ‘A1’}

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 {‘userSet’, ‘never’, ‘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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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’, ‘veryHidden’, ‘hidden’}

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 {‘commIndAndComment’, ‘commIndicator’, ‘commNone’}

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 {‘1920x1200’, ‘1152x882’, ‘1800x1440’, ‘800x600’, ‘1024x768’, ‘640x480’, ‘720x512’, ‘1280x1024’, ‘1152x900’, ‘1600x1200’, ‘544x376’}

thicket

Values must be of type <class ‘bool’>

vml

Values must be of type <class ‘bool’>

openpyxl.workbook.workbook module
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_range(named_range)[source]

Add an existing named_range to the list of named_ranges.

Note

Deprecated: Use workbook.defined_names.append

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

create_sheet(title=None, index=None)[source]

Create a worksheet (at an optional index).

Parameters:
  • title (unicode) – optional title of the sheet
  • index (int) – optional position at which the sheet will be inserted
data_only
excel_base_date
get_active_sheet()[source]

Returns the current active sheet.

Note

Deprecated: Use the .active property

get_index(worksheet)[source]

Return the index of the worksheet.

Note

Deprecated: Use wb.index(worksheet)

get_named_range(name)[source]

Return the range specified by name.

Note

Deprecated: Use workbook.defined_names[name]

get_named_ranges()[source]

Return all named ranges

Note

Deprecated: Use workbook.defined_names.definedName

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.

named_styles

List available named styles

path = '/xl/workbook.xml'
read_only
remove(worksheet)[source]

Remove worksheet from this workbook.

remove_named_range(named_range)[source]

Remove a named_range from this workbook.

Note

Deprecated: Use del workbook.defined_names[name]

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. Subsequents 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,
bounds

Vertices of the range as a tuple

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

shift(col_shift=0, row_shift=0)[source]

Shift 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 bottown by this number of cells
size

Return the size of the range as a dictionary of rows and columns.

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

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

remove(coord)[source]
openpyxl.worksheet.copier module
class openpyxl.worksheet.copier.WorksheetCopy(source_worksheet, target_worksheet)[source]

Bases: object

Copy the values, styles, dimensions and merged cells from one worksheet to another within the same workbook.

copy_worksheet()[source]
openpyxl.worksheet.datavalidation module
class openpyxl.worksheet.datavalidation.DataValidation(type=None, formula1=None, formula2=None, allow_blank=False, showErrorMessage=True, showInputMessage=True, showDropDown=None, allowBlank=None, sqref=(), promptTitle=None, errorStyle=None, error=None, prompt=None, errorTitle=None, imeMode=None, operator=None)[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 descriptve 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 descriptve 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 descriptve name is desired (eg. “underline” for “u”)

imeMode

Value must be one of {‘disabled’, ‘halfKatakana’, ‘fullAlpha’, ‘fullHangul’, ‘halfHangul’, ‘halfAlpha’, ‘off’, ‘hiragana’, ‘noControl’, ‘fullKatakana’, ‘on’}

operator

Value must be one of {‘lessThan’, ‘notEqual’, ‘notBetween’, ‘greaterThan’, ‘lessThanOrEqual’, ‘greaterThanOrEqual’, ‘equal’, ‘between’}

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 descriptve 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 {‘list’, ‘date’, ‘custom’, ‘whole’, ‘textLength’, ‘decimal’, ‘time’}

validation_type

Aliases can be used when either the desired attribute name is not allowed or confusing in Python (eg. “type”) or a more descriptve 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=None, 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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 descriptve 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.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) – 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 {‘lessThan’, ‘notEqual’, ‘greaterThan’, ‘lessThanOrEqual’, ‘greaterThanOrEqual’, ‘equal’}

tagname = 'customFilter'
val

Values must be of type <class ‘str’>

class openpyxl.worksheet.filters.CustomFilters(_and=None, 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 {‘year’, ‘hour’, ‘month’, ‘day’, ‘second’, ‘minute’}

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 {‘aboveAverage’, ‘null’, ‘nextYear’, ‘yesterday’, ‘lastYear’, ‘thisMonth’, ‘yearToDate’, ‘thisYear’, ‘Q1’, ‘M11’, ‘lastMonth’, ‘nextQuarter’, ‘nextWeek’, ‘M7’, ‘M9’, ‘M2’, ‘today’, ‘Q3’, ‘lastWeek’, ‘M5’, ‘thisWeek’, ‘M3’, ‘M6’, ‘M4’, ‘Q2’, ‘M8’, ‘thisQuarter’, ‘M1’, ‘belowAverage’, ‘tomorrow’, ‘Q4’, ‘lastQuarter’, ‘M12’, ‘nextMonth’, ‘M10’}

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=None, showButton=None, 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 descriptve 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 {‘thai’, ‘korea’, ‘gregorianXlitEnglish’, ‘gregorianUs’, ‘japan’, ‘saka’, ‘gregorianArabic’, ‘taiwan’, ‘gregorianMeFrench’, ‘gregorianXlitFrench’, ‘hijri’, ‘gregorian’, ‘hebrew’}

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 {‘4Rating’, ‘4Arrows’, ‘4TrafficLights’, ‘4RedToBlack’, ‘3Symbols’, ‘5Rating’, ‘4ArrowsGray’, ‘3TrafficLights1’, ‘3Signs’, ‘3TrafficLights2’, ‘3ArrowsGray’, ‘3Symbols2’, ‘5Arrows’, ‘5Quarters’, ‘3Arrows’, ‘3Flags’, ‘5ArrowsGray’}

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 {‘4Rating’, ‘4Arrows’, ‘4TrafficLights’, ‘4RedToBlack’, ‘3Symbols’, ‘5Rating’, ‘4ArrowsGray’, ‘3TrafficLights1’, ‘3Signs’, ‘3TrafficLights2’, ‘3ArrowsGray’, ‘3Symbols2’, ‘5Arrows’, ‘5Quarters’, ‘3Arrows’, ‘3Flags’, ‘5ArrowsGray’}

ref
sortBy

Value must be one of {‘cellColor’, ‘fontColor’, ‘icon’, ‘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 {‘stroke’, ‘pinYin’}

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.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'
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 {‘NA’, ‘displayed’, ‘blank’, ‘dash’}

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 {‘landscape’, ‘default’, ‘portrait’}

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.PageBreak(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.properties module
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 descriptve 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.read_only module
class openpyxl.worksheet.read_only.ReadOnlyWorksheet(parent_workbook, title, worksheet_path, xml_source, shared_strings)[source]

Bases: object

calculate_dimension(force=False)[source]
get_squared_range(min_col, min_row, max_col, max_row)[source]

Note

Deprecated: Use ws.iter_rows()

max_column
max_row
min_column
min_row
rows
values
xml_source

Parse xml source on demand, default to Excel archive

openpyxl.worksheet.read_only.read_dimension(source)[source]
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.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’>

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 {‘xml’, ‘worksheet’, ‘queryTable’}

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 {‘sum’, ‘min’, ‘max’, ‘count’, ‘stdDev’, ‘var’, ‘custom’, ‘countNums’, ‘average’}

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 descriptve name is desired (eg. “underline” for “u”)

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 {‘topRight’, ‘bottomRight’, ‘bottomLeft’, ‘topLeft’}

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 {‘topRight’, ‘bottomRight’, ‘bottomLeft’, ‘topLeft’}

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 {‘pageLayout’, ‘normal’, ‘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
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_print_title(n, rows_or_cols='rows')[source]
Print Titles are rows or columns that are repeated on each printed sheet.
This adds n rows or columns at the top or left of the sheet

Note

Deprecated: Set print titles rows or columns directly

add_table(table)[source]
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
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
get_cell_collection()[source]

Return an unordered list of the cells in this worksheet.

Note

Deprecated: Use the ws.values property

get_named_range(range_name)[source]

Returns a 2D array of cells, with optional row and column offsets.

param range_name:
 named range name
type range_name:
 string
rtype:tuple[tuple[openpyxl.cell.cell.Cell]]

Note

Deprecated: Ranges are workbook objects. Use wb.defined_names[range_name]

get_squared_range(min_col, min_row, max_col, max_row)[source]
Returns a 2D array of cells. Will create any cells within the

boundaries that do not already exist

param min_col:smallest column index (1-based index)
type min_col:int
param min_row:smallest row index (1-based index)
type min_row:int
param max_col:largest column index (1-based index)
type max_col:int
param max_row:largest row index (1-based index)
type max_row:int
rtype:generator

Note

Deprecated: Use ws.iter_rows() or ws.iter_cols() depending whether you want rows or columns returned.

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)[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)
Return type:

generator

iter_rows(range_string=None, min_row=None, max_row=None, min_col=None, max_col=None, row_offset=0, column_offset=0)[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:
  • range_string (string) – range string (e.g. ‘A1:B2’) deprecated
  • 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) – smallest row index (1-based index)
  • row_offset (int) – added to min_row and max_row (e.g. 4)
  • column_offset (int) – added to min_col and max_col (e.g. 3)
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]
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 minimium row index containing data (1-based)

Type:int
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
show_summary_below
show_summary_right
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
vba_code
openpyxl.worksheet.worksheet.flatten(results)[source]

Return cell values row-by-row

Note

Deprecated: Use the worksheet.values property

openpyxl.worksheet.worksheet.isgenerator(obj)
openpyxl.worksheet.write_only module
class openpyxl.worksheet.write_only.WriteOnlyWorksheet(parent, title)[source]

Bases: openpyxl.workbook.child._WorkbookChild

Streaming worksheet. Optimised to reduce memory by writing rows just in time. Cells can be styled and have comments Styles for rows and columns must be applied before writing cells

append(row)[source]
Parameters:row (iterable) – iterable containing values to append
close()[source]
filename
freeze_panes
mime_type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml'
print_area
print_title_cols
print_title_rows
writer = None
openpyxl.worksheet.write_only.create_temporary_file(suffix='')[source]
openpyxl.worksheet.write_only.isgenerator(obj)
openpyxl.writer package
Submodules
openpyxl.writer.etree_worksheet module
openpyxl.writer.etree_worksheet.etree_write_cell(xf, worksheet, cell, styled=None)[source]
openpyxl.writer.etree_worksheet.get_rows_to_write(worksheet)[source]

Return all rows, and any cells that they contain

openpyxl.writer.etree_worksheet.lxml_write_cell(xf, worksheet, cell, styled=False)[source]
openpyxl.writer.etree_worksheet.write_cell(xf, worksheet, cell, styled=False)
openpyxl.writer.etree_worksheet.write_row(xf, worksheet, row, row_idx, max_column)[source]
openpyxl.writer.etree_worksheet.write_rows(xf, worksheet)[source]

Write worksheet data to xml.

openpyxl.writer.excel module
class openpyxl.writer.excel.ExcelWriter(workbook, archive)[source]

Bases: object

Write a workbook object to an Excel file.

save(filename)[source]

Write data into the archive.

write_data()[source]

Write the various xml files into the zip archive.

openpyxl.writer.excel.save_dump(workbook, filename)[source]

Save a write-only workbook

openpyxl.writer.excel.save_virtual_workbook(workbook)[source]

Return an in-memory workbook, suitable for a Django response.

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.strings module
openpyxl.writer.strings.write_string_table(string_table)[source]

Write the string table xml.

openpyxl.writer.theme module
openpyxl.writer.theme.write_theme()[source]

Write the theme xml.

openpyxl.writer.workbook module
openpyxl.writer.workbook.get_active_sheet(wb)[source]

Return the index of the active sheet. If the sheet set to active is hidden return the next visible sheet or None

openpyxl.writer.workbook.write_root_rels(workbook)[source]

Write the relationships xml.

openpyxl.writer.workbook.write_workbook(workbook)[source]

Write the core workbook xml.

openpyxl.writer.workbook.write_workbook_rels(workbook)[source]

Write the workbook relationships xml.

openpyxl.writer.worksheet module
openpyxl.writer.worksheet.write_conditional_formatting(worksheet)[source]

Write conditional formatting to xml.

openpyxl.writer.worksheet.write_drawing(worksheet)[source]

Add link to drawing if required

Write worksheet hyperlinks to xml.

openpyxl.writer.worksheet.write_mergecells(ws)[source]

Write merged cells to xml.

openpyxl.writer.worksheet.write_worksheet(worksheet)[source]

Write a worksheet to an xml file.

openpyxl.xml package
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
openpyxl.xml.functions module
openpyxl.xml.functions.fromstring(*args, **kwargs)[source]
openpyxl.xml.functions.iterparse(source, *args, **kw)
openpyxl.xml.functions.localname(node)[source]
openpyxl.xml.functions.safe_iterator(node, tag=None)[source]

Return an iterator or an empty list

openpyxl.xml.functions.safe_iterparse(source, *args, **kw)[source]

Indices and tables

Release Notes

2.5.15 (unreleased)

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

Pull requests

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