Openpyxl
Openpyxl
Release 2.4.0
See AUTHORS
1 Introduction 3
1.1 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Sample code: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 User List 5
5 Installation 11
7 Usage examples 15
7.1 Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
7.2 Cookbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
7.3 Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
7.4 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.5 Read/write large files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.6 Working with styles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.7 Conditional Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.8 Data Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
7.9 Parsing Formulas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9 API Documentation 77
9.1 openpyxl package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
i
11.5 2.3.0-b2 (2015-09-04) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
11.6 2.3.0-b1 (2015-06-29) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
11.7 2.2.6 (unreleased) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
11.8 2.2.5 (2015-06-29) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
11.9 2.2.4 (2015-06-17) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
11.10 2.2.3 (2015-05-26) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
11.11 2.2.2 (2015-04-28) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
11.12 2.2.1 (2015-03-31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
11.13 2.2.0 (2015-03-11) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
11.14 2.2.0-b1 (2015-02-18) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
11.15 2.1.5 (2015-02-18) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
11.16 2.1.4 (2014-12-16) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
11.17 2.1.3 (2014-12-09) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
11.18 2.1.2 (2014-10-23) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
11.19 2.1.1 (2014-10-08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
11.20 2.1.0 (2014-09-21) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
11.21 2.0.5 (2014-08-08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.22 2.0.4 (2014-06-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.23 2.0.3 (2014-05-22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.24 2.0.2 (2014-05-13) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.25 2.0.1 (2014-05-13) brown bag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.26 2.0.0 (2014-05-13) brown bag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
11.27 1.8.6 (2014-05-05) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
11.28 1.8.5 (2014-03-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
11.29 1.8.4 (2014-02-25) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
11.30 1.8.3 (2014-02-09) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
11.31 1.8.2 (2014-01-17) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
11.32 1.8.1 (2014-01-14) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
11.33 1.8.0 (2014-01-08) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230
11.34 1.7.0 (2013-10-31) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
ii
openpyxl Documentation, Release 2.4.0
Contents 1
openpyxl Documentation, Release 2.4.0
2 Contents
CHAPTER 1
Introduction
Openpyxl is a Python library for reading and writing 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.
1.1 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.
3
openpyxl Documentation, Release 2.4.0
4 Chapter 1. Introduction
CHAPTER 2
User List
5
openpyxl Documentation, Release 2.4.0
7
openpyxl Documentation, Release 2.4.0
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 repro-
duced, ...
• 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.6 to 3.5, so if it does not work on
your environment, let us know :-)
9
openpyxl Documentation, Release 2.4.0
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:
or browse https://pypi.python.org/pypi/Pillow/, pick the latest version and head to the bottom of the page for Win-
dows binaries.
11
openpyxl Documentation, Release 2.4.0
12 Chapter 5. Installation
CHAPTER 6
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 hg+https://bitbucket.org/openpyxl/[email protected]#egg=openpyxl
13
openpyxl Documentation, Release 2.4.0
Usage examples
7.1 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 using it
>>> from openpyxl import Workbook
>>> wb = Workbook()
A workbook is always created with at least one worksheet. You can get it by using the
openpyxl.workbook.Workbook.active() property
>>> ws = wb.active
Note: This function uses the _active_sheet_index property, set to 0 by default. Unless you modify its value, you will
always get the first worksheet by using this method.
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 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 sheet_properties.tabColor property:
ws.sheet_properties.tabColor = "1072BA"
Once you gave a worksheet a name, you can get it as a key of the workbook or using the
openpyxl.workbook.Workbook.get_sheet_by_name() method
15
openpyxl Documentation, Release 2.4.0
You can review the names of all worksheets of the workbook with the
openpyxl.workbook.Workbook.get_sheet_names() method
>>> print(wb.get_sheet_names())
['Sheet2', 'New Title', 'Sheet1']
Now we know how to access 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
You can also access a cell using row and column notation:
>>> d = ws.cell(row = 4, column = 2)
Note: When a worksheet is created in memory, it contains no cells. They are created when first accessed. This way
we don’t create objects that would never be accessed, thus reducing the memory footprint.
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
If you need to iterate through all the rows or columns of a file, you can instead use the
openpyxl.worksheet.Worksheet.rows() property:
>>> ws = wb.active
>>> ws['C9'] = 'hello world'
>>> 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>))
7.1. Tutorial 17
openpyxl Documentation, Release 2.4.0
Data storage
The simplest and safest way to save a workbook is by using the openpyxl.workbook.Workbook.save()
method of the openpyxl.workbook.Workbook object:
>>> wb = Workbook()
>>> wb.save('balances.xlsx')
Note: 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.
You can specify the attribute as_template=True, to save the document as a template
>>> wb = load_workbook('document.xlsx')
>>> wb.save('document_template.xltx', as_template=True)
or specify the attribute as_template=False (by default), to save the document template (or document) as document.
>>> wb = load_workbook('document_template.xltx')
>>> wb.save('document.xlsx', as_template=False)
>>> wb = load_workbook('document.xlsx')
>>> wb.save('new_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.
The same way as writing, you can import openpyxl.load_workbook() to open an existing workbook:
>>> from openpyxl import load_workbook
>>> wb2 = load_workbook('test.xlsx')
>>> print wb2.get_sheet_names()
['Sheet2', 'New Title', 'Sheet1']
This ends the tutorial for now, you can proceed to the Simple usage section
7.2 Cookbook
Write a workbook
7.2. Cookbook 19
openpyxl Documentation, Release 2.4.0
>>>
>>> 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="%s" % get_column_letter(col))
>>> print(ws3['AA10'].value)
AA
>>> wb.save(filename = dest_filename)
• 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 formulae
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.
7.2. Cookbook 21
openpyxl Documentation, Release 2.4.0
Inserting an image
7.3 Charts
7.3.1 Charts
Warning: Openpyxl currently supports chart creation within a worksheet only. Charts in existing workbooks will
be lost.
Chart types
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],
]
chart = AreaChart()
chart.title = "Area Chart"
chart.style = 13
chart.x_axis.title = 'Test'
chart.y_axis.title = 'Percentage'
ws.add_chart(chart, "A10")
wb.save("area.xlsx")
7.3. Charts 23
openpyxl Documentation, Release 2.4.0
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],
]
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
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:
7.3. Charts 25
openpyxl Documentation, Release 2.4.0
In bar charts values are plotted as either horizontal bars or vertical columns.
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),
]
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)'
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")
7.3. Charts 27
openpyxl Documentation, Release 2.4.0
BarChart3D,
)
wb = Workbook()
ws = wb.active
rows = [
(None, 2013, 2014),
("Apples", 5, 4),
("Oranges", 6, 2),
("Pears", 8, 3)
]
ws.add_chart(chart, "E5")
wb.save("bar3d.xlsx")
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
"""
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),
]
chart = BubbleChart()
chart.style = 18 # use a preset style
This will produce bubble chart with two series and should look something like this
Line Charts
7.3. Charts 29
openpyxl Documentation, Release 2.4.0
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
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],
]
c1 = LineChart()
c1.title = "Line Chart"
c1.style = 13
c1.y_axis.title = 'Size'
c1.x_axis.title = 'Test Number'
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")
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")
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")
7.3. Charts 31
openpyxl Documentation, Release 2.4.0
3D Line Charts In 3D line charts the third axis is the same as the legend for the series.
from datetime import date
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],
]
c1 = LineChart3D()
c1.title = "3D Line Chart"
c1.legend = None
c1.style = 15
c1.y_axis.title = 'Size'
c1.x_axis.title = 'Test Number'
ws.add_chart(c1, "A10")
wb.save("line3D.xlsx")
7.3. Charts 33
openpyxl Documentation, Release 2.4.0
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],
chart = ScatterChart()
chart.title = "Scatter Chart"
chart.style = 13
chart.x_axis.title = 'Size'
chart.y_axis.title = 'Percentage'
ws.add_chart(chart, "A10")
wb.save("scatter.xlsx")
7.3. Charts 35
openpyxl Documentation, Release 2.4.0
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
data = [
['Pie', 'Sold'],
['Apple', 50],
['Cherry', 30],
['Pumpkin', 10],
['Chocolate', 40],
]
wb = Workbook()
ws = wb.active
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"
ws.add_chart(pie, "D1")
ws = wb.create_sheet(title="Projection")
data = [
['Page', 'Views'],
['Search', 95],
['Products', 4],
['Offers', 0.5],
['Sales', 0.5],
]
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")
ws.add_chart(projected_bar, "A27")
wb.save("pie.xlsx")
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.
7.3. Charts 37
openpyxl Documentation, Release 2.4.0
data = [
['Pie', 'Sold'],
['Apple', 50],
['Cherry', 30],
['Pumpkin', 10],
['Chocolate', 40],
]
wb = Workbook()
ws = wb.active
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")
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
7.3. Charts 39
openpyxl Documentation, Release 2.4.0
data = [
['Pie', 2014, 2015],
['Plain', 40, 50],
['Jam', 2, 10],
['Lime', 20, 30],
['Chocolate', 30, 40],
]
wb = Workbook()
ws = wb.active
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
ws.add_chart(chart, "E1")
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")
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],
7.3. Charts 41
openpyxl Documentation, Release 2.4.0
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")
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:
7.3. Charts 43
openpyxl Documentation, Release 2.4.0
• 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 up-
DownLines.
Volume can be added by combining the stock chart with a bar chart for the volume.
from datetime import date
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, ],
]
# 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()
ws.add_chart(c2, "G10")
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)
# 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
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")
7.3. Charts 45
openpyxl Documentation, Release 2.4.0
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:
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 perspec-
tive.
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],
]
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")
# 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")
7.3. Charts 47
openpyxl Documentation, Release 2.4.0
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)
>>> wb.save("SampleChart.xlsx")
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.
wb = Workbook()
ws = wb.active
rows = [
['Aliens', 2, 3, 4, 5, 6, 7],
['Humans', 10, 40, 50, 20, 10, 50],
]
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'
# 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:
7.3. Charts 49
openpyxl Documentation, Release 2.4.0
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'
legend.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],
]
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)
ws.add_chart(ch1, "B10")
7.3. Charts 51
openpyxl Documentation, Release 2.4.0
xMode="edge",
yMode="edge",
)
)
ch3.title = "Manual chart layout, edge mode"
ws.add_chart(ch3, "B27")
ws.add_chart(ch4, "H27")
wb.save("chart_layout.xlsx")
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
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"
ws.add_chart(c, "C1")
wb.save("pattern.xlsx")
7.3. Charts 53
openpyxl Documentation, Release 2.4.0
Advanced 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
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)
s1.data_points = slices
c1.series = [s1]
c1 += c2 # combine charts
ws.add_chart(c1, "D1")
wb.save("gauge.xlsx")
Using chartsheets
7.3. Charts 55
openpyxl Documentation, Release 2.4.0
Chartsheets
Chartsheets are special worksheets which only contain charts. All the data for the chart must be on a different work-
sheet.
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
cs = wb.create_chartsheet()
rows = [
["Bob", 3],
["Harry", 2],
["James", 4],
]
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")
7.4 Comments
7.4.1 Comments
Warning: Openpyxl currently supports the reading and writing of comment text only. Formatting information is
lost. Comments are not currently supported if use_iterators=True is used.
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'
You cannot assign the same Comment object to two different cells. Doing so raises an AttributeError.
7.4. Comments 57
openpyxl Documentation, Release 2.4.0
Comments present in a workbook when loaded are stored in the comment attribute of their respective cells automati-
cally. 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.
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'] # ws is now an IterableWorksheet
Warning:
• openpyxl.worksheet.read_only.ReadOnlyWorksheet is read-only
Here again, the regular openpyxl.worksheet.worksheet.Worksheet has been replaced by a faster alterna-
tive, the openpyxl.writer.write_only.WriteOnlyWorksheet. When you want to dump large amounts
of data, you might find optimized writer helpful.
>>> from openpyxl import Workbook
>>> wb = Workbook(write_only=True)
>>> ws = wb.create_sheet()
>>>
If you want to have cells with styles or comments then use a openpyxl.writer.write_only.WriteOnlyCell()
>>> from openpyxl import Workbook
>>> wb = Workbook(write_only=True)
>>> ws = wb.create_sheet()
>>> from openpyxl.writer.write_only import WriteOnlyCell
>>> from openpyxl.comments import Comment
>>> from openpyxl.styles import Style, Font
>>> cell = WriteOnlyCell(ws, value="hello world")
>>> cell.font = Font(name='Courrier', size=36)
>>> cell.comment = Comment(text="A comment", author="Author's Name")
This will append one new row with 3 cells, one text cell with custom font and font size, a float and an empty cell that
will be discarded anyway.
Warning:
• Those worksheet only have an append() method, it’s not possible to access independent cells directly
(through cell() or range()). They are write-only.
• It is able to export unlimited amount of data (even more than Excel can handle actually), while keeping
memory usage under 10Mb.
• A workbook using the optimized writer can only be saved once. After that, ev-
ery attempt to save the workbook or append() to an existing worksheet will raise an
openpyxl.utils.exceptions.WorkbookAlreadySaved exception.
Introduction
Styles are used to change the look of your data while displayed on screen. They are also used to determine the number
format being used for a given cell or range of cells.
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)
>>>
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.styles import colors
>>> 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
Colors are usually RGB or aRGB hexvalues. The colors module contains some 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 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")
Header / Footer
Headers and footers use their own formatting language. This is fully supported when writing them but, due to the
complexity and the possibility of nesting, only partially when reading them.
>>> from openpyxl.workbook import Workbook
>>>
>>> wb = Workbook()
>>> ws = wb.worksheets[0]
>>>
>>> ws.header_footer.center_header.text = 'My Excel Page'
>>> ws.header_footer.center_header.font_size = 14
>>> ws.header_footer.center_header.font_name = "Tahoma,Bold"
>>> ws.header_footer.center_header.font_color = "CC3366"
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 worksheet: “codeName”, “enableFormatConditionsCalculation”, “filterMode”, “published”,
“syncHorizontal”, “syncRef”, “syncVertical”, “transitionEvaluation”, “transitionEntry”, “tabColor”. Available fields
for page setup properties: “autoPageBreaks”, “fitToPage”. Available fields for outline properties: “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 PageSetupPr object with the
required parameters. Once done, they can be directly modified by the routine later if needed.
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.
Because the signatures for some rules can be quite verbose there are also some convenience factories for creating them.
Builtin formats
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:
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
>>> # assign the icon set to a rule
>>> from openpyxl.formatting.rule import Rule
>>> rule = Rule(type='iconSet', iconSet=iconset)
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="FF638EC6", showValue=None, minLength=None, maxLen
>>> # assign the data bar to a rule
>>>
>>> # 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 styli
>>> myFont = Font()
>>> myBorder = Border()
>>> ws.conditional_formatting.add('E1:E10',
... FormulaRule(formula=['E1=0'], font=myFont, border=myBorder, fill=redFill))
>>>
>>> wb.save("test.xlsx")
You can add data validation to a workbook but currently cannot read existing data validation.
Examples
>>> # 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.ranges.append('B1:B1048576')
>>>
>>> # Write the sheet out. If you now open the sheet in Excel, you'll find that
Any date:
dv = DataValidation(type="date")
or time:
dv = DataValidation(type="time")
Custom rule:
dv = DataValidation(type="custom",
formula1"=SOMEFORMULA")
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:
– Token.OPEN and Token.CLOSE: these two subtypes are used by PAREN, FUNC, and ARRAY, to de-
scribe 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 semi-
colon. Commas produce tokens of subtype ARG whereas semicolons produce tokens of subtype ROW
8.1 Development
With the ongoing development of openpyxl, there is occasional information useful to assist developers.
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.
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.
Use PEP-8 except when implementing attributes for roundtripping but always use Python data conventions (boolean,
None, etc.) Note exceptions in docstrings.
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
$ hg up 2.4
$ virtualenv openpyxl
$ cd openpyxl
$ source bin/activate
$ pip install -U -r requirements.txt
$ python setup.py develop
71
openpyxl Documentation, Release 2.4.0
8.1.5 Testing
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
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.
Please see Testing on Windows for additional information on setting up and testing on Windows.
8.1.6 Contributing
Contributions in the form of pull requests are always welcome. Don’t forget to add yourself to the list of authors!
We use a “major.minor.patch” numbering system, ie. 2.4.0. 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 should be submitted to the current, unreleased development branch. Eg. if the current release is 2.4.0,
pull requests should be made to the 2.4 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
8.1.9 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 bench-
marking package to measure the performance of different components.
8.1. Development 73
openpyxl Documentation, Release 2.4.0
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.
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.
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 develop-
ment work.
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
8.2.3 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
5. Move all these files to a folder called “downloads” in your openpyxl checkout
6. Install the project requirements:
pip install --download downloads -r requirements.txt
pip install --no-index --find-links downloads -r requirements.txt
8.2.4 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
9.1.1 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)
Bases: openpyxl.styles.styleable.StyleableObject
Describes cell associated properties.
Properties of interest include style, type, value, and address.
ERROR_CODES = (‘#NULL!’, ‘#DIV/0!’, ‘#VALUE!’, ‘#REF!’, ‘#NAME?’, ‘#NUM!’, ‘#N/A’)
TYPE_BOOL = ‘b’
TYPE_ERROR = ‘e’
TYPE_FORMULA = ‘f’
TYPE_FORMULA_CACHE_STRING = ‘str’
TYPE_INLINE = ‘inlineStr’
TYPE_NULL = ‘n’
TYPE_NUMERIC = ‘n’
TYPE_STRING = ‘s’
VALID_TYPES = (‘s’, ‘f’, ‘n’, ‘b’, ‘n’, ‘inlineStr’, ‘e’, ‘str’)
anchor
returns the expected position of a cell in pixels from the top-left of the sheet. For example, A1 anchor
should be (0,0).
Return type tuple(int, int)
base_date
77
openpyxl Documentation, Release 2.4.0
check_error(value)
Tries to convert Error” else N/A
check_string(value)
Check string coding, length, and line break character
col_idx
column
comment
Returns the comment associated with this cell
Return type openpyxl.comments.Comment
coordinate
data_type
encoding
guess_types
hyperlink
Return the hyperlink target or an empty string
internal_value
Always returns the value for excel.
is_date
Whether the value is formatted as a date
Return type bool
offset(row=0, column=0)
Returns a cell location relative to this cell.
Parameters
• row (int) – number of rows to offset
• column (int) – number of columns to offset
Return type openpyxl.cell.Cell
parent
row
set_explicit_value(value=None, data_type=’s’)
Coerce values according to their explicit type
value
Get or set the value held in the cell. ‘:rtype: depends on the value (string, float, int or ‘
‘datetime.datetime)’
openpyxl.cell.interface module
class openpyxl.cell.interface.AbstractCell(value=None)
Bases: abc.ABC
base_date
comment
coordinate
encoding
guess_types
internal_value
is_date
number_format
offset(row=0, column=0)
style
value
openpyxl.cell.read_only module
class openpyxl.cell.read_only.ReadOnlyCell(sheet, row, column, value, data_type=’n’,
style_id=0)
Bases: object
alignment
base_date
border
column
coordinate
data_type
fill
font
internal_value
is_date
number_format
parent
protection
row
shared_strings
style
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)
Bases: openpyxl.styles.fonts.Font
Font for inline text because, yes what you need are different objects with the same elements but different con-
straints.
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 {‘minor’, ‘major’}
shadow
Values must be of type <class ‘bool’>
strike
Values must be of type <class ‘bool’>
sz
Values must be of type <class ‘float’>
tagname = ‘RPrElt’
u
Value must be one of {‘single’, ‘doubleAccounting’, ‘double’, ‘singleAccounting’}
vertAlign
Value must be one of {‘superscript’, ‘subscript’, ‘baseline’}
class openpyxl.cell.text.PhoneticProperties(fontId=None, type=None, alignment=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
alignment
Value must be one of {‘noControl’, ‘center’, ‘distributed’, ‘left’}
fontId
Values must be of type <class ‘int’>
type
Value must be one of {‘halfwidthKatakana’, ‘noConversion’, ‘fullwidthKatakana’, ‘Hiragana’}
class openpyxl.cell.text.PhoneticText(sb=None, eb=None, t=None)
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 Values must be of type <class ‘str’>
class openpyxl.cell.text.RichText(rPr=None, t=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
rPr
Values must be of type <class ‘openpyxl.cell.text.InlineFont’>
t
Values must be of type <class ‘str’>
tagname = ‘RElt’
class openpyxl.cell.text.Text(t=None, r=(), rPh=(), phoneticPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
content
Text stripped of all formatting
phoneticPr
Values must be of type <class ‘openpyxl.cell.text.PhoneticProperties’>
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)
Bases: openpyxl.chart.area_chart._AreaChartBase
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
dropLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}
ser
A sequence (list or tuple) that may only contain objects of the declared type
tagname = ‘areaChart’
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
class openpyxl.chart.area_chart.AreaChart3D(gapDepth=None, **kw)
Bases: openpyxl.chart.area_chart.AreaChart
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
dropLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
gapDepth
Values must be of type <class ‘float’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}
ser
A sequence (list or tuple) that may only contain objects of the declared type
tagname = ‘area3DChart’
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
z_axis
Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>
openpyxl.chart.axis module
class openpyxl.chart.axis.ChartLines(spPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘chartLines’
class openpyxl.chart.axis.DateAxis(auto=None, lblOffset=None, baseTimeUnit=None, ma-
jorUnit=1, majorTimeUnit=None, minorUnit=None, minor-
TimeUnit=None, extLst=None, **kw)
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’, ‘r’, ‘l’, ‘t’}
baseTimeUnit
Value must be one of {‘years’, ‘days’, ‘months’}
crossAx
Values must be of type <class ‘int’>
crosses
Value must be one of {‘max’, ‘min’, ‘autoZero’}
crossesAt
Values must be of type <class ‘float’>
delete
Values must be of type <class ‘bool’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
lblOffset
Values must be of type <class ‘int’>
majorGridlines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
majorTickMark
Value must be one of {‘in’, ‘out’, ‘cross’}
majorTimeUnit
Value must be one of {‘years’, ‘days’, ‘months’}
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 {‘in’, ‘out’, ‘cross’}
minorTimeUnit
Value must be one of {‘years’, ‘days’, ‘months’}
minorUnit
Values must be of type <class ‘float’>
numFmt
Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>
scaling
Values must be of type <class ‘openpyxl.chart.axis.Scaling’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘dateAx’
tickLblPos
Value must be one of {‘low’, ‘nextTo’, ‘high’}
title
Values must be of type <class ‘openpyxl.chart.title.Title’>
txPr
Values must be of type <class ‘openpyxl.chart.text.RichText’>
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 {‘in’, ‘out’, ‘cross’}
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 {‘in’, ‘out’, ‘cross’}
minorUnit
Values must be of type <class ‘float’>
numFmt
Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>
scaling
Values must be of type <class ‘openpyxl.chart.axis.Scaling’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘valAx’
tickLblPos
Value must be one of {‘low’, ‘nextTo’, ‘high’}
title
Values must be of type <class ‘openpyxl.chart.title.Title’>
txPr
Values must be of type <class ‘openpyxl.chart.text.RichText’>
class openpyxl.chart.axis.Scaling(logBase=None, orientation=’minMax’, max=None, min=None,
extLst=None)
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)
Bases: openpyxl.chart.axis._BaseAxis
axId
Values must be of type <class ‘int’>
axPos
Value must be one of {‘b’, ‘r’, ‘l’, ‘t’}
crossAx
Values must be of type <class ‘int’>
crosses
Value must be one of {‘max’, ‘min’, ‘autoZero’}
crossesAt
Values must be of type <class ‘float’>
delete
Values must be of type <class ‘bool’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
majorGridlines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
majorTickMark
Value must be one of {‘in’, ‘out’, ‘cross’}
minorGridlines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
minorTickMark
Value must be one of {‘in’, ‘out’, ‘cross’}
numFmt
Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>
scaling
Values must be of type <class ‘openpyxl.chart.axis.Scaling’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘serAx’
tickLblPos
Value must be one of {‘low’, ‘nextTo’, ‘high’}
tickLblSkip
Values must be of type <class ‘int’>
tickMarkSkip
Values must be of type <class ‘int’>
title
Values must be of type <class ‘openpyxl.chart.title.Title’>
txPr
Values must be of type <class ‘openpyxl.chart.text.RichText’>
class openpyxl.chart.axis.TextAxis(auto=None, lblAlgn=None, lblOffset=100, tickLblSkip=None,
tickMarkSkip=None, noMultiLvlLbl=None, extLst=None,
**kw)
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’, ‘r’, ‘l’, ‘t’}
crossAx
Values must be of type <class ‘int’>
crosses
Value must be one of {‘max’, ‘min’, ‘autoZero’}
crossesAt
Values must be of type <class ‘float’>
delete
Values must be of type <class ‘bool’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
lblAlgn
Value must be one of {‘ctr’, ‘r’, ‘l’}
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 {‘in’, ‘out’, ‘cross’}
minorGridlines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
minorTickMark
Value must be one of {‘in’, ‘out’, ‘cross’}
noMultiLvlLbl
Values must be of type <class ‘bool’>
numFmt
Values must be of type <class ‘openpyxl.chart.data_source.NumFmt’>
scaling
Values must be of type <class ‘openpyxl.chart.axis.Scaling’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘catAx’
tickLblPos
Value must be one of {‘low’, ‘nextTo’, ‘high’}
tickLblSkip
Values must be of type <class ‘int’>
tickMarkSkip
Values must be of type <class ‘int’>
title
Values must be of type <class ‘openpyxl.chart.title.Title’>
txPr
Values must be of type <class ‘openpyxl.chart.text.RichText’>
openpyxl.chart.bar_chart module
class openpyxl.chart.bar_chart.BarChart(gapWidth=150, overlap=None, serLines=None,
axId=None, extLst=None, **kw)
Bases: openpyxl.chart.bar_chart._BarChartBase
barDir
Value must be one of {‘col’, ‘bar’}
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
gapWidth
Values must be of type <class ‘float’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘clustered’, ‘percentStacked’}
overlap
Values must be of type <class ‘float’>
ser
A sequence (list or tuple) that may only contain objects of the declared type
serLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
tagname = ‘barChart’
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
class openpyxl.chart.bar_chart.BarChart3D(gapWidth=150, gapDepth=150, shape=None, ser-
Lines=None, axId=None, extLst=None, **kw)
Bases: openpyxl.chart.bar_chart._BarChartBase, openpyxl.chart._3d._3DBase
backWall
Values must be of type <class ‘openpyxl.chart._3d.Surface’>
barDir
Value must be one of {‘col’, ‘bar’}
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
floor
Values must be of type <class ‘openpyxl.chart._3d.Surface’>
gapDepth
Values must be of type <class ‘float’>
gapWidth
Values must be of type <class ‘float’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘clustered’, ‘percentStacked’}
ser
A sequence (list or tuple) that may only contain objects of the declared type
serLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
shape
Value must be one of {‘coneToMax’, ‘pyramid’, ‘pyramidToMax’, ‘cylinder’, ‘box’, ‘cone’}
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, bub-
ble3D=None, bubbleScale=None, showNeg-
Bubbles=None, sizeRepresents=None,
axId=None, extLst=None)
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’>
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, back-
Wall=None, plotArea=None, legend=None,
plotVisOnly=None, dispBlanksAs=’gap’,
showDLblsOverMax=None, extLst=None)
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 {‘zero’, ‘span’, ‘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.chartspace.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’>
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.chartspace.ExternalData(autoUpdate=None, id=None)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
dLbl
Values must be of type <class ‘openpyxl.chart.label.DataLabel’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
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=())
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)
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.PlotArea(layout=None, dTable=None, spPr=None,
areaChart=None, area3DChart=None,
lineChart=None, line3DChart=None,
stockChart=None, radarChart=None, scatter-
Chart=None, pieChart=None, pie3DChart=None,
doughnutChart=None, barChart=None,
bar3DChart=None, ofPieChart=None, sur-
faceChart=None, surface3DChart=None, bub-
bleChart=None, valAx=(), catAx=(), serAx=(),
dateAx=(), extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
area3DChart
Values must be of type <class ‘openpyxl.chart.area_chart.AreaChart3D’>
areaChart
Values must be of type <class ‘openpyxl.chart.area_chart.AreaChart’>
bar3DChart
Values must be of type <class ‘openpyxl.chart.bar_chart.BarChart3D’>
barChart
Values must be of type <class ‘openpyxl.chart.bar_chart.BarChart’>
bubbleChart
Values must be of type <class ‘openpyxl.chart.bubble_chart.BubbleChart’>
catAx
A sequence (list or tuple) that may only contain objects of the declared type
dTable
Values must be of type <class ‘openpyxl.chart.chartspace.DataTable’>
dateAx
A sequence (list or tuple) that may only contain objects of the declared type
doughnutChart
Values must be of type <class ‘openpyxl.chart.pie_chart.DoughnutChart’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
layout
Values must be of type <class ‘openpyxl.chart.layout.Layout’>
line3DChart
Values must be of type <class ‘openpyxl.chart.line_chart.LineChart3D’>
lineChart
Values must be of type <class ‘openpyxl.chart.line_chart.LineChart’>
ofPieChart
Values must be of type <class ‘openpyxl.chart.pie_chart.ProjectedPieChart’>
pie3DChart
Values must be of type <class ‘openpyxl.chart.pie_chart.PieChart3D’>
pieChart
Values must be of type <class ‘openpyxl.chart.pie_chart.PieChart’>
radarChart
Values must be of type <class ‘openpyxl.chart.radar_chart.RadarChart’>
scatterChart
Values must be of type <class ‘openpyxl.chart.scatter_chart.ScatterChart’>
serAx
A sequence (list or tuple) that may only contain objects of the declared type
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
stockChart
Values must be of type <class ‘openpyxl.chart.stock_chart.StockChart’>
surface3DChart
Values must be of type <class ‘openpyxl.chart.surface_chart.SurfaceChart3D’>
surfaceChart
Values must be of type <class ‘openpyxl.chart.surface_chart.SurfaceChart’>
tagname = ‘plotArea’
to_tree(tagname=None, idx=None)
valAx
A sequence (list or tuple) that may only contain objects of the declared type
class openpyxl.chart.chartspace.PrintSettings(headerFooter=None, pageMargins=None,
pageSetup=None)
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.worksheet.page.PageMargins’>
pageSetup
Values must be of type <class ‘openpyxl.worksheet.page.PrintPageSetup’>
tagname = ‘printSettings’
class openpyxl.chart.chartspace.Protection(chartObject=None, data=None, format-
ting=None, selection=None, userInter-
face=None)
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’>
class openpyxl.chart.chartspace.RelId
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’>
class openpyxl.chart.data_source.NumVal(idx=None, formatCode=None, v=None)
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 ‘float’>
class openpyxl.chart.data_source.StrData(ptCount=None, pt=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
pt
Values must be of type <class ‘openpyxl.chart.data_source.StrVal’>
ptCount
Values must be of type <class ‘int’>
tagname = ‘strData’
class openpyxl.chart.data_source.StrRef(f=None, strCache=None, extLst=None)
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)
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)
Bases: openpyxl.descriptors.nested.NestedMinMax
allow_none = True
max = 500
min = 0
class openpyxl.chart.descriptors.NestedOverlap(**kw)
Bases: openpyxl.descriptors.nested.NestedMinMax
allow_none = True
max = 100
min = -100
class openpyxl.chart.descriptors.NumberFormatDescriptor(*args, **kw)
Bases: openpyxl.descriptors.base.Typed
Allow direct assignment of format code
allow_none = True
expected_type
alias of NumFmt
openpyxl.chart.error_bar module
class openpyxl.chart.error_bar.ErrorBars(errDir=None, errBarType=’both’, errVal-
Type=’fixedVal’, noEndCap=None, plus=None,
minus=None, val=None, spPr=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
errBarType
Value must be one of {‘plus’, ‘both’, ‘minus’}
errDir
Value must be one of {‘y’, ‘x’}
errValType
Value must be one of {‘percentage’, ‘cust’, ‘fixedVal’, ‘stdDev’, ‘stdErr’}
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
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’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘errBars’
val
Values must be of type <class ‘float’>
openpyxl.chart.label module
class openpyxl.chart.label.DataLabel(idx=0, **kw)
Bases: openpyxl.chart.label._DataLabelBase
dLblPos
Value must be one of {‘bestFit’, ‘inEnd’, ‘r’, ‘ctr’, ‘l’, ‘b’, ‘inBase’, ‘outEnd’, ‘t’}
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=(), **kw)
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 {‘bestFit’, ‘inEnd’, ‘r’, ‘ctr’, ‘l’, ‘b’, ‘inBase’, ‘outEnd’, ‘t’}
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)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
h
Values must be of type <class ‘float’>
hMode
Value must be one of {‘edge’, ‘factor’}
layoutTarget
Value must be one of {‘inner’, ‘outer’}
tagname = ‘manualLayout’
w
Values must be of type <class ‘float’>
wMode
Value must be one of {‘edge’, ‘factor’}
x
Values must be of type <class ‘float’>
xMode
Value must be one of {‘edge’, ‘factor’}
y
Values must be of type <class ‘float’>
yMode
Value must be one of {‘edge’, ‘factor’}
openpyxl.chart.legend module
class openpyxl.chart.legend.Legend(legendPos=’r’, legendEntry=None, layout=None, over-
lay=None, spPr=None, txPr=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
layout
Values must be of type <class ‘openpyxl.chart.layout.Layout’>
legendEntry
Values must be of type <class ‘openpyxl.chart.legend.LegendEntry’>
legendPos
Value must be one of {‘b’, ‘r’, ‘l’, ‘tr’, ‘t’}
overlay
Values must be of type <class ‘bool’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
tagname = ‘legend’
txPr
Values must be of type <class ‘openpyxl.chart.text.RichText’>
class openpyxl.chart.legend.LegendEntry(idx=0, delete=False, txPr=None, extLst=None)
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, axId=None,
extLst=None, **kw)
Bases: openpyxl.chart.line_chart._LineChartBase
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
dropLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}
hiLowLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
marker
Values must be of type <class ‘bool’>
ser
A sequence (list or tuple) that may only contain objects of the declared type
smooth
Values must be of type <class ‘bool’>
tagname = ‘lineChart’
upDownBars
Values must be of type <class ‘openpyxl.chart.updown_bars.UpDownBars’>
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis._BaseAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
class openpyxl.chart.line_chart.LineChart3D(gapDepth=None, hiLowLines=None, upDown-
Bars=None, marker=None, smooth=None,
axId=None, **kw)
Bases: openpyxl.chart.line_chart._LineChartBase
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
dropLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
gapDepth
Values must be of type <class ‘float’>
grouping
Value must be one of {‘stacked’, ‘standard’, ‘percentStacked’}
hiLowLines
Values must be of type <class ‘openpyxl.chart.axis.ChartLines’>
marker
Values must be of type <class ‘bool’>
ser
A sequence (list or tuple) that may only contain objects of the declared type
smooth
Values must be of type <class ‘bool’>
tagname = ‘line3DChart’
upDownBars
Values must be of type <class ‘openpyxl.chart.updown_bars.UpDownBars’>
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis.TextAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
z_axis
Values must be of type <class ‘openpyxl.chart.axis.SeriesAxis’>
openpyxl.chart.marker module
class openpyxl.chart.marker.DataPoint(idx=None, invertIfNegative=None, marker=None, bub-
ble3D=None, explosion=None, spPr=None, pictureOp-
tions=None, extLst=None)
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’>
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
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 {‘star’, ‘square’, ‘diamond’, ‘auto’, ‘triangle’, ‘picture’, ‘plus’, ‘circle’, ‘dash’, ‘dot’,
‘x’}
tagname = ‘marker’
openpyxl.chart.picture module
class openpyxl.chart.picture.PictureOptions(applyToFront=None, applyToSides=None,
applyToEnd=None, pictureFormat=None,
pictureStackUnit=None)
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=())
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)
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)
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)
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)
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’>
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’, ‘pos’, ‘cust’, ‘percent’, ‘val’}
tagname = ‘ofPieChart’
varyColors
Values must be of type <class ‘bool’>
openpyxl.chart.radar_chart module
class openpyxl.chart.radar_chart.RadarChart(radarStyle=’standard’, varyColors=None,
ser=(), dLbls=None, axId=None, extLst=None)
Bases: openpyxl.chart._chart.ChartBase
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
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’
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.reference module
class openpyxl.chart.reference.DummyWorksheet(title)
Bases: object
class openpyxl.chart.reference.Reference(worksheet=None, min_col=None,
min_row=None, max_col=None, max_row=None,
range_string=None)
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()
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, axId=None,
extLst=None)
Bases: openpyxl.chart._chart.ChartBase
dLbls
Values must be of type <class ‘openpyxl.chart.label.DataLabelList’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
scatterStyle
Value must be one of {‘lineMarker’, ‘smooth’, ‘smoothMarker’, ‘line’, ‘marker’}
ser
A sequence (list or tuple) that may only contain objects of the declared type
tagname = ‘scatterChart’
varyColors
Values must be of type <class ‘bool’>
x_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
y_axis
Values must be of type <class ‘openpyxl.chart.axis.NumericAxis’>
openpyxl.chart.series module
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’>
class openpyxl.chart.series.SeriesLabel(strRef=None, v=None)
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’>
class openpyxl.chart.series.XYSeries(idx=0, order=0, tx=None, spPr=None, pictureOp-
tions=None, dPt=(), dLbls=None, trendline=None,
errBars=None, cat=None, val=None, invertIfNeg-
ative=None, shape=None, xVal=None, yVal=None,
bubbleSize=None, bubble3D=None, marker=None,
smooth=None, explosion=None)
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, ti-
tle=None, title_from_data=False)
Convenience Factory for creating chart data series.
openpyxl.chart.shapes module
class openpyxl.chart.shapes.GraphicalProperties(bwMode=None, xfrm=None,
noFill=None, solidFill=None, grad-
Fill=None, pattFill=None, ln=None,
scene3d=None, custGeom=None, prst-
Geom=None, sp3d=None, extLst=None)
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 {‘gray’, ‘blackWhite’, ‘hidden’, ‘auto’, ‘grayWhite’, ‘ltGray’, ‘white’, ‘clr’, ‘in-
vGray’, ‘blackGray’, ‘black’}
custGeom
Values must be of type <class ‘openpyxl.drawing.shapes.CustomGeometry2D’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
gradFill
Values must be of type <class ‘openpyxl.drawing.fill.GradientFillProperties’>
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.shapes.PresetGeometry2D’>
scene3d
Values must be of type <class ‘openpyxl.drawing.shapes.Scene3D’>
solidFill
Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>
sp3d
Values must be of type <class ‘openpyxl.drawing.shapes.Shape3D’>
tagname = ‘spPr’
xfrm
Values must be of type <class ‘openpyxl.drawing.shapes.Transform2D’>
openpyxl.chart.stock_chart module
class openpyxl.chart.stock_chart.StockChart(ser=(), dLbls=None, dropLines=None, hiLow-
Lines=None, upDownBars=None, axId=None,
extLst=None)
Bases: openpyxl.chart._chart.ChartBase
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’>
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
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=())
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)
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(axId=None, **kw)
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)
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
tagname = ‘rich’
openpyxl.chart.title module
class openpyxl.chart.title.Title(tx=None, layout=None, overlay=None, spPr=None, txPr=None,
extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
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’
tx
Values must be of type <class ‘openpyxl.chart.text.Text’>
txPr
Values must be of type <class ‘openpyxl.drawing.text.RichTextProperties’>
class openpyxl.chart.title.TitleDescriptor(*args, **kw)
Bases: openpyxl.descriptors.base.Typed
allow_none = True
expected_type
alias of Title
openpyxl.chart.title.title_maker(text)
openpyxl.chart.trendline module
class openpyxl.chart.trendline.Trendline(name=None, spPr=None, trendlineType=’linear’,
order=None, period=None, forward=None, back-
ward=None, intercept=None, dispRSqr=None, dis-
pEq=None, trendlineLbl=None, extLst=None)
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’>
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 {‘linear’, ‘power’, ‘poly’, ‘movingAvg’, ‘exp’, ‘log’}
class openpyxl.chart.trendline.TrendlineLabel(layout=None, tx=None, numFmt=None,
spPr=None, txPr=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
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’
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, down-
Bars=None, extLst=None)
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
Subpackages
openpyxl.chartsheet.tests package
Submodules
openpyxl.chartsheet.tests.test_chartsheet module
openpyxl.chartsheet.tests.test_chartsheet.Chartsheet()
class openpyxl.chartsheet.tests.test_chartsheet.DummyWorkbook
Bases: object
class openpyxl.chartsheet.tests.test_chartsheet.TestChartsheet
Bases: object
test_ctor(Chartsheet)
test_read(Chartsheet)
test_write(Chartsheet)
test_write_charts(Chartsheet)
openpyxl.chartsheet.tests.test_custom module
openpyxl.chartsheet.tests.test_custom.CustomChartsheetView()
openpyxl.chartsheet.tests.test_custom.CustomChartsheetViews()
class openpyxl.chartsheet.tests.test_custom.TestCustomChartsheetView
Bases: object
test_read(CustomChartsheetView)
test_write(CustomChartsheetView)
class openpyxl.chartsheet.tests.test_custom.TestCustomChartsheetViews
Bases: object
test_read(CustomChartsheetViews)
test_write(CustomChartsheetViews)
openpyxl.chartsheet.tests.test_properties module
openpyxl.chartsheet.tests.test_properties.ChartsheetProperties()
class openpyxl.chartsheet.tests.test_properties.TestChartsheetPr
Bases: object
test_read(ChartsheetProperties)
test_write(ChartsheetProperties)
openpyxl.chartsheet.tests.test_protection module
openpyxl.chartsheet.tests.test_protection.ChartsheetProtection()
class openpyxl.chartsheet.tests.test_protection.TestChartsheetProtection
Bases: object
test_read(ChartsheetProtection)
test_write(ChartsheetProtection)
openpyxl.chartsheet.tests.test_publish module
class openpyxl.chartsheet.tests.test_publish.TestWebPublishItems
Bases: object
test_read(WebPublishItems)
test_write(WebPublishItems)
class openpyxl.chartsheet.tests.test_publish.TestWebPulishItem
Bases: object
test_read(WebPublishItem)
test_write(WebPublishItem)
openpyxl.chartsheet.tests.test_publish.WebPublishItem()
openpyxl.chartsheet.tests.test_publish.WebPublishItems()
openpyxl.chartsheet.tests.test_relation module
openpyxl.chartsheet.tests.test_relation.DrawingHF()
openpyxl.chartsheet.tests.test_relation.SheetBackgroundPicture()
class openpyxl.chartsheet.tests.test_relation.TestDrawingHF
Bases: object
test_read(DrawingHF)
test_write(DrawingHF)
class openpyxl.chartsheet.tests.test_relation.TestSheetBackgroundPicture
Bases: object
test_read(SheetBackgroundPicture)
test_write(SheetBackgroundPicture)
openpyxl.chartsheet.tests.test_views module
openpyxl.chartsheet.tests.test_views.ChartsheetView()
openpyxl.chartsheet.tests.test_views.ChartsheetViewList()
class openpyxl.chartsheet.tests.test_views.TestChartsheetView
Bases: object
test_read(ChartsheetView)
test_write(ChartsheetView)
class openpyxl.chartsheet.tests.test_views.TestChartsheetViewList
Bases: object
test_read(ChartsheetViewList)
test_write(ChartsheetViewList)
Submodules
openpyxl.chartsheet.chartsheet module
class openpyxl.chartsheet.chartsheet.Chartsheet(sheetPr=None, sheetViews=None,
sheetProtection=None, cus-
tomSheetViews=None, pageMar-
gins=None, pageSetup=None, head-
erFooter=None, drawing=None, draw-
ingHF=None, picture=None, webPub-
lishItems=None, extLst=None, par-
ent=None, title=’‘, sheet_state=’visible’)
Bases: openpyxl.workbook.child._WorkbookChild, openpyxl.descriptors.serialisable.Serialisa
add_chart(chart)
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’>
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()
webPublishItems
Values must be of type <class ‘openpyxl.chartsheet.publish.WebPublishItems’>
openpyxl.chartsheet.custom module
openpyxl.chartsheet.properties module
class openpyxl.chartsheet.properties.ChartsheetProperties(published=None, co-
deName=None, tab-
Color=None)
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, ob-
jects=None, hash-
Value=None, spin-
Count=None, salt-
Value=None, algo-
rithmName=None, pass-
word=None)
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
hash_password(password)
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, source-
Type=None, sourceRef=None,
sourceObject=None, destination-
File=None, title=None, autoRepub-
lish=None)
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 {‘query’, ‘sheet’, ‘pivotTable’, ‘label’, ‘printArea’, ‘autoFilter’, ‘range’, ‘chart’}
tagname = ‘webPublishItem’
title
Values must be of type <class ‘str’>
class openpyxl.chartsheet.publish.WebPublishItems(count=None, webPublishItem=None)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
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’>
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’>
class openpyxl.chartsheet.relation.SheetBackgroundPicture(id)
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)
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)
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=())
Bases: openpyxl.descriptors.serialisable.Serialisable
author
A sequence (list or tuple) that may only contain objects of the declared type
tagname = ‘authors’
openpyxl.comments.comments module
class openpyxl.comments.comments.Comment(text, author)
Bases: object
parent
text
Any comment text stripped of all formatting.
openpyxl.comments.properties module
class openpyxl.comments.properties.Comment(ref=’‘, authorId=0, guid=None, shapeId=0,
text=None, commentPr=None, author=None)
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.properties.Properties’>
content
Remove all inline formatting and stuff
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.properties.CommentSheet(authors=None, commentList=None,
extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
authors
Values must be of type <class ‘openpyxl.comments.author.AuthorList’>
commentList
Wrap a sequence in an containing object
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
tagname = ‘comments’
to_tree()
class openpyxl.comments.properties.ObjectAnchor(moveWithCells=None, sizeWith-
Cells=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
moveWithCells
Values must be of type <class ‘bool’>
sizeWithCells
Values must be of type <class ‘bool’>
openpyxl.comments.reader module
openpyxl.comments.reader.get_comments_file(worksheet_path, archive, valid_files)
Returns the XML filename in the archive which contains the comments for the spreadsheet with codename
sheet_codename.
openpyxl.comments.reader.read_comments(ws, xml_source)
Given a worksheet and the XML of its comments file, assigns comments to cells
openpyxl.comments.writer module
class openpyxl.comments.writer.CommentWriter(sheet)
Bases: object
write_comments()
Create list of comments and authors
write_comments_vml()
openpyxl.descriptors package
class openpyxl.descriptors.MetaSerialisable
Bases: type
class openpyxl.descriptors.MetaStrict
Bases: type
class openpyxl.descriptors.Strict
Bases: object
Submodules
openpyxl.descriptors.base module
class openpyxl.descriptors.base.ASCII(*args, **kw)
Bases: openpyxl.descriptors.base.Typed
expected_type
alias of bytes
class openpyxl.descriptors.base.Alias(alias)
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)
Bases: openpyxl.descriptors.base.Convertible
expected_type
alias of bool
class openpyxl.descriptors.base.Convertible(*args, **kw)
Bases: openpyxl.descriptors.base.Typed
Values must be convertible to a particular type
class openpyxl.descriptors.base.DateTime(*args, **kw)
Bases: openpyxl.descriptors.base.Typed
expected_type
alias of datetime
class openpyxl.descriptors.base.Default(name=None, **kw)
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)
Bases: object
expected_type
alias of tuple
class openpyxl.descriptors.base.Typed(*args, **kw)
Bases: openpyxl.descriptors.base.Descriptor
Values must of a particular type
allow_none = False
expected_type
alias of NoneType
nested = False
openpyxl.descriptors.excel module
class openpyxl.descriptors.excel.Base64Binary(name=None, **kw)
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.Extension(uri=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
uri
Values must be of type <class ‘str’>
class openpyxl.descriptors.excel.ExtensionList(ext=())
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)
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)
Bases: openpyxl.descriptors.base.MatchPattern
pattern = ‘[0-9a-fA-F]+$’
class openpyxl.descriptors.excel.Percentage(name=None, **kw)
Bases: openpyxl.descriptors.base.MatchPattern
pattern = ‘((100)|([0-9][0-9]?))(\\.[0-9][0-9]?)?%’
class openpyxl.descriptors.excel.Relation(*args, **kw)
Bases: openpyxl.descriptors.base.String
allow_none = True
namespace = ‘http://schemas.openxmlformats.org/officeDocument/2006/relationships’
class openpyxl.descriptors.excel.TextPoint(**kw)
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 int
max = 400000
min = -400000
openpyxl.descriptors.namespace module
openpyxl.descriptors.namespace.namespaced(obj, tagname, namespace=None)
Utility to create a namespaced tag for an object
openpyxl.descriptors.nested module
class openpyxl.descriptors.nested.EmptyTag(*args, **kw)
Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.Bool
Boolean if a tag exists or not.
from_tree(node)
to_tree(tagname=None, value=None, namespace=None)
class openpyxl.descriptors.nested.Nested(name=None, **kw)
Bases: openpyxl.descriptors.base.Descriptor
attribute = ‘val’
from_tree(node)
nested = True
to_tree(tagname=None, value=None, namespace=None)
class openpyxl.descriptors.nested.NestedBool(*args, **kw)
Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Bool
from_tree(node)
class openpyxl.descriptors.nested.NestedFloat(*args, **kw)
Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Float
class openpyxl.descriptors.nested.NestedInteger(*args, **kw)
Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.Integer
class openpyxl.descriptors.nested.NestedMinMax(**kw)
Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.MinMax
class openpyxl.descriptors.nested.NestedNoneSet(name=None, **kw)
Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.NoneSet
class openpyxl.descriptors.nested.NestedSet(name=None, **kw)
Bases: openpyxl.descriptors.nested.Nested, openpyxl.descriptors.base.Set
class openpyxl.descriptors.nested.NestedString(*args, **kw)
Bases: openpyxl.descriptors.nested.NestedValue, openpyxl.descriptors.base.String
class openpyxl.descriptors.nested.NestedText(*args, **kw)
Bases: openpyxl.descriptors.nested.NestedValue
Represents any nested tag with the value as the contents of the tag
from_tree(node)
to_tree(tagname=None, value=None, namespace=None)
openpyxl.descriptors.sequence module
class openpyxl.descriptors.sequence.NestedSequence(name=None, **kw)
Bases: openpyxl.descriptors.sequence.Sequence
Wrap a sequence in an containing object
count = False
from_tree(node)
to_tree(tagname, obj, namespace=None)
class openpyxl.descriptors.sequence.Sequence(name=None, **kw)
Bases: openpyxl.descriptors.base.Descriptor
A sequence (list or tuple) that may only contain objects of the declared type
expected_type
alias of NoneType
idx_base = 0
seq_types = (<class ‘list’>, <class ‘tuple’>)
to_tree(tagname, obj, namespace=None)
Convert the sequence represented by the descriptor to an XML element
unique = False
class openpyxl.descriptors.sequence.ValueSequence(name=None, **kw)
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)
to_tree(tagname, obj, namespace=None)
openpyxl.descriptors.serialisable module
class openpyxl.descriptors.serialisable.Serialisable
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 __ele-
ments__ = child elements
classmethod from_tree(node)
Create object from XML
idx_base = 0
namespace = None
tagname
to_tree(tagname=None, idx=None, namespace=None)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
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 {‘lightSlateGray’, ‘oldLace’, ‘ltPink’, ‘lightSteelBlue’, ‘peachPuff’, ‘steel-
Blue’, ‘dkViolet’, ‘greenYellow’, ‘darkGrey’, ‘moccasin’, ‘snow’, ‘yellow’, ‘firebrick’, ‘medTurquoise’,
‘gray’, ‘lightSkyBlue’, ‘darkOrchid’, ‘medSeaGreen’, ‘salmon’, ‘mistyRose’, ‘black’, ‘aquamarine’,
‘dkOrange’, ‘mintCream’, ‘red’, ‘magenta’, ‘ltSalmon’, ‘indianRed’, ‘dkGoldenrod’, ‘lightSeaGreen’,
‘paleVioletRed’, ‘royalBlue’, ‘darkSlateBlue’, ‘pink’, ‘crimson’, ‘darkGoldenrod’, ‘darkTurquoise’,
‘dimGray’, ‘tomato’, ‘dkOliveGreen’, ‘springGreen’, ‘dkKhaki’, ‘mediumSlateBlue’, ‘lightBlue’,
‘lavenderBlush’, ‘darkViolet’, ‘lightCyan’, ‘bisque’, ‘lightSlateGrey’, ‘oliveDrab’, ‘peru’, ‘darkBlue’,
‘wheat’, ‘blanchedAlmond’, ‘maroon’, ‘midnightBlue’, ‘darkGray’, ‘grey’, ‘antiqueWhite’, ‘darkOrange’,
‘dkGreen’, ‘goldenrod’, ‘orchid’, ‘navy’, ‘ltGray’, ‘ltSkyBlue’, ‘ltSteelBlue’, ‘medSlateBlue’, ‘nava-
joWhite’, ‘violet’, ‘gold’, ‘dkSlateGrey’, ‘dkTurquoise’, ‘paleGoldenrod’, ‘dkGray’, ‘medPurple’, ‘medi-
umPurple’, ‘darkGreen’, ‘darkSeaGreen’, ‘saddleBrown’, ‘dkRed’, ‘skyBlue’, ‘teal’, ‘ghostWhite’, ‘medi-
umVioletRed’, ‘ltSlateGray’, ‘cornsilk’, ‘seaGreen’, ‘silver’, ‘honeydew’, ‘ltGreen’, ‘dkSeaGreen’, ‘deep-
Pink’, ‘medAquamarine’, ‘dkMagenta’, ‘lightCoral’, ‘medBlue’, ‘medOrchid’, ‘darkSlateGray’, ‘aqua’,
‘beige’, ‘ltSeaGreen’, ‘lemonChiffon’, ‘orange’, ‘whiteSmoke’, ‘blue’, ‘lightGoldenrodYellow’, ‘cyan’,
‘dkCyan’, ‘indigo’, ‘chocolate’, ‘lightSalmon’, ‘coral’, ‘darkSalmon’, ‘dkGrey’, ‘sienna’, ‘dkSalmon’,
‘papayaWhip’, ‘darkCyan’, ‘thistle’, ‘khaki’, ‘lightPink’, ‘dimGrey’, ‘ltGrey’, ‘cornflowerBlue’, ‘ltSlate-
Grey’, ‘purple’, ‘orangeRed’, ‘ivory’, ‘dkOrchid’, ‘floralWhite’, ‘linen’, ‘rosyBrown’, ‘gainsboro’, ‘olive’,
‘hotPink’, ‘lightGreen’, ‘dkBlue’, ‘dodgerBlue’, ‘darkRed’, ‘blueViolet’, ‘darkSlateGrey’, ‘ltGolden-
rodYellow’, ‘mediumOrchid’, ‘burlyWood’, ‘ltYellow’, ‘lawnGreen’, ‘azure’, ‘limeGreen’, ‘lightYel-
low’, ‘dkSlateBlue’, ‘ltBlue’, ‘slateBlue’, ‘mediumAquamarine’, ‘tan’, ‘green’, ‘slateGrey’, ‘lightGray’,
‘medVioletRed’, ‘dkSlateGray’, ‘lavender’, ‘darkKhaki’, ‘cadetBlue’, ‘mediumSeaGreen’, ‘darkOlive-
Green’, ‘paleGreen’, ‘ltCoral’, ‘mediumBlue’, ‘sandyBrown’, ‘paleTurquoise’, ‘mediumSpringGreen’,
‘brown’, ‘fuchsia’, ‘deepSkyBlue’, ‘plum’, ‘seaShell’, ‘ltCyan’, ‘forestGreen’, ‘slateGray’, ‘lightGrey’,
‘chartreuse’, ‘aliceBlue’, ‘lime’, ‘mediumTurquoise’, ‘darkMagenta’, ‘medSpringGreen’, ‘yellowGreen’,
‘powderBlue’, ‘turquoise’, ‘white’}
schemeClr
Value must be one of {‘accent3’, ‘phClr’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘bg1’, ‘lt2’, ‘accent2’,
‘accent1’, ‘dk2’, ‘lt1’, ‘accent4’, ‘bg2’, ‘folHlink’, ‘tx1’, ‘tx2’}
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)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
accent1
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
accent2
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
accent3
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
accent4
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
accent5
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
accent6
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
bg1
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
bg2
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
folHlink
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
hlink
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
tagname = ‘clrMapOvr’
tx1
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
tx2
Value must be one of {‘accent3’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘lt2’, ‘accent2’, ‘accent1’, ‘dk2’,
‘lt1’, ‘accent4’, ‘folHlink’}
class openpyxl.drawing.colors.HSLColor(hue=None, sat=None, lum=None)
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)
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.SystemColor(val=’bg1’, 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)
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 ‘openpyxl.styles.colors.RGB’>
lum
Values must be of type <class ‘int’>
lumMod
Values must be of type <class ‘int’>
lumOff
Values must be of type <class ‘int’>
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 {‘accent3’, ‘phClr’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘bg1’, ‘lt2’, ‘accent2’,
‘accent1’, ‘dk2’, ‘lt1’, ‘accent4’, ‘bg2’, ‘folHlink’, ‘tx1’, ‘tx2’}
class openpyxl.drawing.colors.Transform
Bases: openpyxl.descriptors.serialisable.Serialisable
openpyxl.drawing.drawing module
class openpyxl.drawing.drawing.Drawing
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()
return (x, y, w, h) in EMU
height
set_dimension(w=0, h=0)
width
openpyxl.drawing.effect module
class openpyxl.drawing.effect.AlphaBiLevelEffect(thresh=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
thresh
Values must be of type <class ‘int’>
class openpyxl.drawing.effect.AlphaCeilingEffect
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.AlphaFloorEffect
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.AlphaInverseEffect
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.AlphaModulateEffect(cont=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cont
Values must be of type <class ‘openpyxl.drawing.effect.EffectContainer’>
class openpyxl.drawing.effect.AlphaModulateFixedEffect(amt=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
amt
Values must be of type <class ‘int’>
class openpyxl.drawing.effect.AlphaReplaceEffect(a=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
a
Values must be of type <class ‘int’>
class openpyxl.drawing.effect.BiLevelEffect(thresh=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
thresh
Values must be of type <class ‘int’>
class openpyxl.drawing.effect.BlurEffect(rad=None, grow=None)
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
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.ColorChangeEffect(useA=None, clrFrom=None,
clrTo=None)
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
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.DuotoneEffect
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.EffectContainer(type=None, name=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
name
Values must be of type <class ‘str’>
type
Value must be one of {‘sib’, ‘tree’}
class openpyxl.drawing.effect.EffectList(blur=None, fillOverlay=None, glow=None, inner-
Shdw=None, outerShdw=None, prstShdw=None, re-
flection=None, softEdge=None)
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.OuterShadowEffect’>
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
blend
Value must be one of {‘over’, ‘mult’, ‘screen’, ‘darken’, ‘lighten’}
class openpyxl.drawing.effect.GlowEffect(rad=None, **kw)
Bases: openpyxl.drawing.colors.ColorChoice
hslClr
Values must be of type <class ‘openpyxl.drawing.colors.HSLColor’>
prstClr
Value must be one of {‘lightSlateGray’, ‘oldLace’, ‘ltPink’, ‘lightSteelBlue’, ‘peachPuff’, ‘steel-
Blue’, ‘dkViolet’, ‘greenYellow’, ‘darkGrey’, ‘moccasin’, ‘snow’, ‘yellow’, ‘firebrick’, ‘medTurquoise’,
‘gray’, ‘lightSkyBlue’, ‘darkOrchid’, ‘medSeaGreen’, ‘salmon’, ‘mistyRose’, ‘black’, ‘aquamarine’,
‘dkOrange’, ‘mintCream’, ‘red’, ‘magenta’, ‘ltSalmon’, ‘indianRed’, ‘dkGoldenrod’, ‘lightSeaGreen’,
‘paleVioletRed’, ‘royalBlue’, ‘darkSlateBlue’, ‘pink’, ‘crimson’, ‘darkGoldenrod’, ‘darkTurquoise’,
‘dimGray’, ‘tomato’, ‘dkOliveGreen’, ‘springGreen’, ‘dkKhaki’, ‘mediumSlateBlue’, ‘lightBlue’,
‘lavenderBlush’, ‘darkViolet’, ‘lightCyan’, ‘bisque’, ‘lightSlateGrey’, ‘oliveDrab’, ‘peru’, ‘darkBlue’,
‘wheat’, ‘blanchedAlmond’, ‘maroon’, ‘midnightBlue’, ‘darkGray’, ‘grey’, ‘antiqueWhite’, ‘darkOrange’,
‘dkGreen’, ‘goldenrod’, ‘orchid’, ‘navy’, ‘ltGray’, ‘ltSkyBlue’, ‘ltSteelBlue’, ‘medSlateBlue’, ‘nava-
joWhite’, ‘violet’, ‘gold’, ‘dkSlateGrey’, ‘dkTurquoise’, ‘paleGoldenrod’, ‘dkGray’, ‘medPurple’, ‘medi-
umPurple’, ‘darkGreen’, ‘darkSeaGreen’, ‘saddleBrown’, ‘dkRed’, ‘skyBlue’, ‘teal’, ‘ghostWhite’, ‘medi-
umVioletRed’, ‘ltSlateGray’, ‘cornsilk’, ‘seaGreen’, ‘silver’, ‘honeydew’, ‘ltGreen’, ‘dkSeaGreen’, ‘deep-
Pink’, ‘medAquamarine’, ‘dkMagenta’, ‘lightCoral’, ‘medBlue’, ‘medOrchid’, ‘darkSlateGray’, ‘aqua’,
‘beige’, ‘ltSeaGreen’, ‘lemonChiffon’, ‘orange’, ‘whiteSmoke’, ‘blue’, ‘lightGoldenrodYellow’, ‘cyan’,
‘dkCyan’, ‘indigo’, ‘chocolate’, ‘lightSalmon’, ‘coral’, ‘darkSalmon’, ‘dkGrey’, ‘sienna’, ‘dkSalmon’,
‘papayaWhip’, ‘darkCyan’, ‘thistle’, ‘khaki’, ‘lightPink’, ‘dimGrey’, ‘ltGrey’, ‘cornflowerBlue’, ‘ltSlate-
Grey’, ‘purple’, ‘orangeRed’, ‘ivory’, ‘dkOrchid’, ‘floralWhite’, ‘linen’, ‘rosyBrown’, ‘gainsboro’, ‘olive’,
‘hotPink’, ‘lightGreen’, ‘dkBlue’, ‘dodgerBlue’, ‘darkRed’, ‘blueViolet’, ‘darkSlateGrey’, ‘ltGolden-
rodYellow’, ‘mediumOrchid’, ‘burlyWood’, ‘ltYellow’, ‘lawnGreen’, ‘azure’, ‘limeGreen’, ‘lightYel-
low’, ‘dkSlateBlue’, ‘ltBlue’, ‘slateBlue’, ‘mediumAquamarine’, ‘tan’, ‘green’, ‘slateGrey’, ‘lightGray’,
‘medVioletRed’, ‘dkSlateGray’, ‘lavender’, ‘darkKhaki’, ‘cadetBlue’, ‘mediumSeaGreen’, ‘darkOlive-
Green’, ‘paleGreen’, ‘ltCoral’, ‘mediumBlue’, ‘sandyBrown’, ‘paleTurquoise’, ‘mediumSpringGreen’,
‘brown’, ‘fuchsia’, ‘deepSkyBlue’, ‘plum’, ‘seaShell’, ‘ltCyan’, ‘forestGreen’, ‘slateGray’, ‘lightGrey’,
‘chartreuse’, ‘aliceBlue’, ‘lime’, ‘mediumTurquoise’, ‘darkMagenta’, ‘medSpringGreen’, ‘yellowGreen’,
‘powderBlue’, ‘turquoise’, ‘white’}
rad
Values must be of type <class ‘float’>
schemeClr
Value must be one of {‘accent3’, ‘phClr’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘bg1’, ‘lt2’, ‘accent2’,
‘accent1’, ‘dk2’, ‘lt1’, ‘accent4’, ‘bg2’, ‘folHlink’, ‘tx1’, ‘tx2’}
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
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.effect.HSLEffect(hue=None, sat=None, lum=None)
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)
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 {‘lightSlateGray’, ‘oldLace’, ‘ltPink’, ‘lightSteelBlue’, ‘peachPuff’, ‘steel-
Blue’, ‘dkViolet’, ‘greenYellow’, ‘darkGrey’, ‘moccasin’, ‘snow’, ‘yellow’, ‘firebrick’, ‘medTurquoise’,
‘gray’, ‘lightSkyBlue’, ‘darkOrchid’, ‘medSeaGreen’, ‘salmon’, ‘mistyRose’, ‘black’, ‘aquamarine’,
‘dkOrange’, ‘mintCream’, ‘red’, ‘magenta’, ‘ltSalmon’, ‘indianRed’, ‘dkGoldenrod’, ‘lightSeaGreen’,
‘paleVioletRed’, ‘royalBlue’, ‘darkSlateBlue’, ‘pink’, ‘crimson’, ‘darkGoldenrod’, ‘darkTurquoise’,
‘dimGray’, ‘tomato’, ‘dkOliveGreen’, ‘springGreen’, ‘dkKhaki’, ‘mediumSlateBlue’, ‘lightBlue’,
‘lavenderBlush’, ‘darkViolet’, ‘lightCyan’, ‘bisque’, ‘lightSlateGrey’, ‘oliveDrab’, ‘peru’, ‘darkBlue’,
‘wheat’, ‘blanchedAlmond’, ‘maroon’, ‘midnightBlue’, ‘darkGray’, ‘grey’, ‘antiqueWhite’, ‘darkOrange’,
‘dkGreen’, ‘goldenrod’, ‘orchid’, ‘navy’, ‘ltGray’, ‘ltSkyBlue’, ‘ltSteelBlue’, ‘medSlateBlue’, ‘nava-
joWhite’, ‘violet’, ‘gold’, ‘dkSlateGrey’, ‘dkTurquoise’, ‘paleGoldenrod’, ‘dkGray’, ‘medPurple’, ‘medi-
umPurple’, ‘darkGreen’, ‘darkSeaGreen’, ‘saddleBrown’, ‘dkRed’, ‘skyBlue’, ‘teal’, ‘ghostWhite’, ‘medi-
umVioletRed’, ‘ltSlateGray’, ‘cornsilk’, ‘seaGreen’, ‘silver’, ‘honeydew’, ‘ltGreen’, ‘dkSeaGreen’, ‘deep-
Pink’, ‘medAquamarine’, ‘dkMagenta’, ‘lightCoral’, ‘medBlue’, ‘medOrchid’, ‘darkSlateGray’, ‘aqua’,
‘beige’, ‘ltSeaGreen’, ‘lemonChiffon’, ‘orange’, ‘whiteSmoke’, ‘blue’, ‘lightGoldenrodYellow’, ‘cyan’,
‘dkCyan’, ‘indigo’, ‘chocolate’, ‘lightSalmon’, ‘coral’, ‘darkSalmon’, ‘dkGrey’, ‘sienna’, ‘dkSalmon’,
prst
Value must be one of {‘shdw7’, ‘shdw19’, ‘shdw1’, ‘shdw4’, ‘shdw20’, ‘shdw10’, ‘shdw2’, ‘shdw15’,
‘shdw11’, ‘shdw14’, ‘shdw13’, ‘shdw12’, ‘shdw17’, ‘shdw8’, ‘shdw3’, ‘shdw5’, ‘shdw6’, ‘shdw9’,
‘shdw16’, ‘shdw18’}
prstClr
Value must be one of {‘lightSlateGray’, ‘oldLace’, ‘ltPink’, ‘lightSteelBlue’, ‘peachPuff’, ‘steel-
Blue’, ‘dkViolet’, ‘greenYellow’, ‘darkGrey’, ‘moccasin’, ‘snow’, ‘yellow’, ‘firebrick’, ‘medTurquoise’,
‘gray’, ‘lightSkyBlue’, ‘darkOrchid’, ‘medSeaGreen’, ‘salmon’, ‘mistyRose’, ‘black’, ‘aquamarine’,
‘dkOrange’, ‘mintCream’, ‘red’, ‘magenta’, ‘ltSalmon’, ‘indianRed’, ‘dkGoldenrod’, ‘lightSeaGreen’,
‘paleVioletRed’, ‘royalBlue’, ‘darkSlateBlue’, ‘pink’, ‘crimson’, ‘darkGoldenrod’, ‘darkTurquoise’,
‘dimGray’, ‘tomato’, ‘dkOliveGreen’, ‘springGreen’, ‘dkKhaki’, ‘mediumSlateBlue’, ‘lightBlue’,
‘lavenderBlush’, ‘darkViolet’, ‘lightCyan’, ‘bisque’, ‘lightSlateGrey’, ‘oliveDrab’, ‘peru’, ‘darkBlue’,
‘wheat’, ‘blanchedAlmond’, ‘maroon’, ‘midnightBlue’, ‘darkGray’, ‘grey’, ‘antiqueWhite’, ‘darkOrange’,
‘dkGreen’, ‘goldenrod’, ‘orchid’, ‘navy’, ‘ltGray’, ‘ltSkyBlue’, ‘ltSteelBlue’, ‘medSlateBlue’, ‘nava-
joWhite’, ‘violet’, ‘gold’, ‘dkSlateGrey’, ‘dkTurquoise’, ‘paleGoldenrod’, ‘dkGray’, ‘medPurple’, ‘medi-
umPurple’, ‘darkGreen’, ‘darkSeaGreen’, ‘saddleBrown’, ‘dkRed’, ‘skyBlue’, ‘teal’, ‘ghostWhite’, ‘medi-
umVioletRed’, ‘ltSlateGray’, ‘cornsilk’, ‘seaGreen’, ‘silver’, ‘honeydew’, ‘ltGreen’, ‘dkSeaGreen’, ‘deep-
Pink’, ‘medAquamarine’, ‘dkMagenta’, ‘lightCoral’, ‘medBlue’, ‘medOrchid’, ‘darkSlateGray’, ‘aqua’,
‘beige’, ‘ltSeaGreen’, ‘lemonChiffon’, ‘orange’, ‘whiteSmoke’, ‘blue’, ‘lightGoldenrodYellow’, ‘cyan’,
‘dkCyan’, ‘indigo’, ‘chocolate’, ‘lightSalmon’, ‘coral’, ‘darkSalmon’, ‘dkGrey’, ‘sienna’, ‘dkSalmon’,
‘papayaWhip’, ‘darkCyan’, ‘thistle’, ‘khaki’, ‘lightPink’, ‘dimGrey’, ‘ltGrey’, ‘cornflowerBlue’, ‘ltSlate-
Grey’, ‘purple’, ‘orangeRed’, ‘ivory’, ‘dkOrchid’, ‘floralWhite’, ‘linen’, ‘rosyBrown’, ‘gainsboro’, ‘olive’,
‘hotPink’, ‘lightGreen’, ‘dkBlue’, ‘dodgerBlue’, ‘darkRed’, ‘blueViolet’, ‘darkSlateGrey’, ‘ltGolden-
rodYellow’, ‘mediumOrchid’, ‘burlyWood’, ‘ltYellow’, ‘lawnGreen’, ‘azure’, ‘limeGreen’, ‘lightYel-
low’, ‘dkSlateBlue’, ‘ltBlue’, ‘slateBlue’, ‘mediumAquamarine’, ‘tan’, ‘green’, ‘slateGrey’, ‘lightGray’,
‘medVioletRed’, ‘dkSlateGray’, ‘lavender’, ‘darkKhaki’, ‘cadetBlue’, ‘mediumSeaGreen’, ‘darkOlive-
Green’, ‘paleGreen’, ‘ltCoral’, ‘mediumBlue’, ‘sandyBrown’, ‘paleTurquoise’, ‘mediumSpringGreen’,
‘brown’, ‘fuchsia’, ‘deepSkyBlue’, ‘plum’, ‘seaShell’, ‘ltCyan’, ‘forestGreen’, ‘slateGray’, ‘lightGrey’,
‘chartreuse’, ‘aliceBlue’, ‘lime’, ‘mediumTurquoise’, ‘darkMagenta’, ‘medSpringGreen’, ‘yellowGreen’,
‘powderBlue’, ‘turquoise’, ‘white’}
schemeClr
Value must be one of {‘accent3’, ‘phClr’, ‘accent5’, ‘hlink’, ‘dk1’, ‘accent6’, ‘bg1’, ‘lt2’, ‘accent2’,
‘accent1’, ‘dk2’, ‘lt1’, ‘accent4’, ‘bg2’, ‘folHlink’, ‘tx1’, ‘tx2’}
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
algn
Value must be one of {‘br’, ‘r’, ‘ctr’, ‘l’, ‘b’, ‘tl’, ‘bl’, ‘tr’, ‘t’}
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
rad
Values must be of type <class ‘float’>
class openpyxl.drawing.effect.TintEffect(hue=None, amt=None)
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, noAd-
justHandles=None, noChangeArrowheads=None, noChange-
ShapeType=None, extLst=None, alphaBiLevel=None, al-
phaCeiling=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)
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’, ‘screen’, ‘hqprint’, ‘email’}
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’>
link
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>, srcRect=None)
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=None, lin=None, path=None,
tileRect=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
flip
Value must be one of {‘y’, ‘xy’, ‘x’}
gsLst
Values must be of type <class ‘openpyxl.drawing.fill.GradientStopList’>
lin
Values must be of type <class ‘openpyxl.drawing.fill.LinearShadeProperties’>
path
Values must be of type <class ‘openpyxl.drawing.fill.PathShadeProperties’>
rotWithShape
Values must be of type <class ‘bool’>
tagname = ‘gradFill’
tileRect
Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>
class openpyxl.drawing.fill.GradientStop(pos=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
pos
Values must be of type <class ‘float’>
tagname = ‘gradStop’
class openpyxl.drawing.fill.GradientStopList(gs=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
gs
A sequence (list or tuple) that may only contain objects of the declared type
tagname = ‘gradStopLst’
class openpyxl.drawing.fill.LinearShadeProperties(ang=None, scaled=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
ang
Values must be of type <class ‘int’>
scaled
Values must be of type <class ‘bool’>
class openpyxl.drawing.fill.PathShadeProperties(path=None, fillToRect=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
fillToRect
Values must be of type <class ‘openpyxl.drawing.fill.RelativeRect’>
path
Value must be one of {‘shape’, ‘rect’, ‘circle’}
class openpyxl.drawing.fill.PatternFillProperties(prst=None, fgClr=None, bg-
Clr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
bgClr
Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>
fgClr
Values must be of type <class ‘openpyxl.drawing.colors.ColorChoice’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
prst
Value must be one of {‘ltHorz’, ‘trellis’, ‘lgCheck’, ‘pct60’, ‘diagBrick’, ‘dkVert’, ‘pct80’, ‘narVert’,
‘dotDmnd’, ‘weave’, ‘dashVert’, ‘pct50’, ‘plaid’, ‘dashUpDiag’, ‘pct10’, ‘narHorz’, ‘dkDnDiag’, ‘pct20’,
‘wdUpDiag’, ‘solidDmnd’, ‘openDmnd’, ‘pct40’, ‘lgConfetti’, ‘pct5’, ‘dkHorz’, ‘pct70’, ‘smGrid’, ‘dash-
Horz’, ‘wdDnDiag’, ‘smCheck’, ‘pct90’, ‘wave’, ‘divot’, ‘horz’, ‘pct30’, ‘cross’, ‘zigZag’, ‘dashDnDiag’,
‘dotGrid’, ‘sphere’, ‘pct75’, ‘ltUpDiag’, ‘ltVert’, ‘dnDiag’, ‘dkUpDiag’, ‘horzBrick’, ‘ltDnDiag’, ‘sm-
Confetti’, ‘shingle’, ‘upDiag’, ‘lgGrid’, ‘diagCross’, ‘vert’, ‘pct25’}
tagname = ‘pattFill’
class openpyxl.drawing.fill.RelativeRect(l=None, t=None, r=None, b=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
b
Values must be of type <class ‘float’>
l
Values must be of type <class ‘float’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
r
Values must be of type <class ‘float’>
t
Values must be of type <class ‘float’>
tagname = ‘rect’
class openpyxl.drawing.fill.StretchInfoProperties(fillRect=<openpyxl.drawing.fill.RelativeRect
object>)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
algn
Value must be one of {‘br’, ‘r’, ‘ctr’, ‘l’, ‘b’, ‘tl’, ‘bl’, ‘tr’, ‘t’}
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.graphic module
class openpyxl.drawing.graphic.ChartRelation(id)
Bases: openpyxl.descriptors.serialisable.Serialisable
id
Values must be of type <class ‘str’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/chart’
tagname = ‘chart’
class openpyxl.drawing.graphic.Connection(id=None, idx=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
id
Values must be of type <class ‘int’>
idx
Values must be of type <class ‘int’>
class openpyxl.drawing.graphic.Connector(macro=None, fPublished=None, nvCxnSpPr=None,
spPr=None, style=None)
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.graphic.ConnectorNonVisual’>
spPr
Values must be of type <class ‘openpyxl.chart.shapes.GraphicalProperties’>
style
Values must be of type <class ‘openpyxl.drawing.shapes.ShapeStyle’>
class openpyxl.drawing.graphic.ConnectorLocking(extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
class openpyxl.drawing.graphic.ConnectorNonVisual(cNvPr=None, cNvCxnSpPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cNvCxnSpPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualConnectorProperties’>
cNvPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualDrawingProps’>
class openpyxl.drawing.graphic.GraphicData(uri=’http://schemas.openxmlformats.org/drawingml/2006/chart’,
chart=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
chart
Values must be of type <class ‘openpyxl.drawing.graphic.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, fPub-
lished=None)
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.shapes.Transform2D’>
class openpyxl.drawing.graphic.GraphicFrameLocking(noGrp=None, noDrilldown=None,
noSelect=None, noChangeA-
spect=None, noMove=None, noRe-
size=None, extLst=None)
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)
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’
chOff
Values must be of type <class ‘openpyxl.drawing.shapes.Point2D’>
ext
Values must be of type <class ‘openpyxl.drawing.shapes.PositiveSize2D’>
flipH
Values must be of type <class ‘bool’>
flipV
Values must be of type <class ‘bool’>
off
Values must be of type <class ‘openpyxl.drawing.shapes.Point2D’>
rot
Values must be of type <class ‘int’>
class openpyxl.drawing.graphic.NonVisualConnectorProperties(cxnSpLocks=None,
stCxn=None,
endCxn=None,
extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cxnSpLocks
Values must be of type <class ‘openpyxl.drawing.graphic.ConnectorLocking’>
endCxn
Values must be of type <class ‘openpyxl.drawing.graphic.Connection’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
stCxn
Values must be of type <class ‘openpyxl.drawing.graphic.Connection’>
class openpyxl.drawing.graphic.NonVisualDrawingProps(id=None, name=None, de-
scr=None, hidden=None, ti-
tle=None, hlinkClick=None,
hlinkHover=None, extLst=None)
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.graphic.NonVisualGraphicFrame(cNvPr=None, cNvGraph-
icFramePr=None)
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.graphic.NonVisualDrawingProps’>
tagname = ‘nvGraphicFramePr’
class openpyxl.drawing.graphic.NonVisualGraphicFrameProperties(graphicFrameLocks=None,
extLst=None)
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’
class openpyxl.drawing.graphic.NonVisualGroupDrawingShapeProps(grpSpLocks=None,
extLst=None)
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.graphic.GroupLocking’>
class openpyxl.drawing.graphic.NonVisualGroupShape(cNvPr=None, cNvGrpSpPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cNvGrpSpPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualGroupDrawingShapeProps’>
cNvPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualDrawingProps’>
class openpyxl.drawing.graphic.NonVisualPictureProperties(preferRelativeResize=None,
picLocks=None,
extLst=None)
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.graphic.PictureLocking’>
preferRelativeResize
Values must be of type <class ‘bool’>
tagname = ‘cNvPicPr’
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.graphic.PictureNonVisual(cNvPr=None, cNvPicPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cNvPicPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualPictureProperties’>
cNvPr
Values must be of type <class ‘openpyxl.drawing.graphic.NonVisualDrawingProps’>
tagname = ‘nvPicPr’
openpyxl.drawing.image module
class openpyxl.drawing.image.Image(img, coordinates=((0, 0), (1, 1)), size=(None, None),
nochangeaspect=True, nochangearrowheads=True)
Bases: object
Raw Image class
anchor(cell, anchortype=’absolute’)
anchors the image to the given cell optional parameter anchortype supports ‘absolute’ or ‘oneCell’
openpyxl.drawing.image.bounding_box(bw, bh, w, h)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
d
Values must be of type <class ‘int’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
sp
Values must be of type <class ‘int’>
tagname = ‘ds’
class openpyxl.drawing.line.DashStopList(ds=None)
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)
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’, ‘arrow’, ‘none’, ‘diamond’, ‘triangle’, ‘oval’}
w
Value must be one of {‘lg’, ‘med’, ‘sm’}
class openpyxl.drawing.line.LineJoinMiterProperties(lim=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
lim
Values must be of type <class ‘int’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
tagname = ‘miter’
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, mitre=None, head-
End=None, tailEnd=None, extLst=None)
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 {‘sq’, ‘flat’, ‘rnd’}
cmpd
Value must be one of {‘thickThin’, ‘tri’, ‘thinThick’, ‘sng’, ‘dbl’}
custDash
Values must be of type <class ‘openpyxl.drawing.line.DashStop’>
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 ‘openpyxl.drawing.line.LineJoinMiterProperties’>
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 {‘solid’, ‘sysDashDot’, ‘lgDash’, ‘lgDashDot’, ‘lgDashDotDot’, ‘sysDashDotDot’,
‘sysDash’, ‘dashDot’, ‘dash’, ‘sysDot’, ‘dot’}
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’>
openpyxl.drawing.shape module
class openpyxl.drawing.shape.Shape(chart, coordinates=((0, 0), (1, 1)), text=None,
scheme=’accent1’)
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” “rightAr-
row” “leftArrow” “upArrow” “downArrow” “stripedRightArrow” “notchedRightArrow” “bentUpAr-
row” “leftRightArrow” “upDownArrow” “leftUpArrow” “leftRightUpArrow” “quadArrow” “leftArrow-
Callout” “rightArrowCallout” “upArrowCallout” “downArrowCallout” “leftRightArrowCallout” “up-
DownArrowCallout” “quadArrowCallout” “bentArrow” “uturnArrow” “circularArrow” “leftCircularAr-
row” “leftRightCircularArrow” “curvedRightArrow” “curvedLeftArrow” “curvedUpArrow” “curved-
DownArrow” “swooshArrow” “cube” “can” “lightningBolt” “heart” “sun” “moon” “smileyFace” “ir-
regularSeal1” “irregularSeal2” “foldedCorner” “bevel” “frame” “halfFrame” “corner” “diagStripe”
“chord” “arc” “leftBracket” “rightBracket” “leftBrace” “rightBrace” “bracketPair” “bracePair” “straight-
Connector1” “bentConnector2” “bentConnector3” “bentConnector4” “bentConnector5” “curvedCon-
nector2” “curvedConnector3” “curvedConnector4” “curvedConnector5” “callout1” “callout2” “call-
out3” “accentCallout1” “accentCallout2” “accentCallout3” “borderCallout1” “borderCallout2” “bor-
derCallout3” “accentBorderCallout1” “accentBorderCallout2” “accentBorderCallout3” “wedgeRectCall-
out” “wedgeRoundRectCallout” “wedgeEllipseCallout” “cloudCallout” “cloud” “ribbon” “ribbon2” “el-
lipseRibbon” “ellipseRibbon2” “leftRightRibbon” “verticalScroll” “horizontalScroll” “wave” “double-
Wave” “plus” “flowChartProcess” “flowChartDecision” “flowChartInputOutput” “flowChartPredefined-
Process” “flowChartInternalStorage” “flowChartDocument” “flowChartMultidocument” “flowChartTer-
minator” “flowChartPreparation” “flowChartManualInput” “flowChartManualOperation” “flowChartCon-
nector” “flowChartPunchedCard” “flowChartPunchedTape” “flowChartSummingJunction” “flowChar-
tOr” “flowChartCollate” “flowChartSort” “flowChartExtract” “flowChartMerge” “flowChartOfflineStor-
age” “flowChartOnlineStorage” “flowChartMagneticTape” “flowChartMagneticDisk” “flowChartMag-
neticDrum” “flowChartDisplay” “flowChartDelay” “flowChartAlternateProcess” “flowChartOffpageCon-
nector” “actionButtonBlank” “actionButtonHome” “actionButtonHelp” “actionButtonInformation” “ac-
tionButtonForwardNext” “actionButtonBackPrevious” “actionButtonEnd” “actionButtonBeginning” “ac-
tionButtonReturn” “actionButtonDocument” “actionButtonSound” “actionButtonMovie” “gear6” “gear9”
openpyxl.drawing.shapes module
class openpyxl.drawing.shapes.AdjPoint2D(x=None, y=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
x
Values must be of type <class ‘int’>
y
Values must be of type <class ‘int’>
class openpyxl.drawing.shapes.AdjustHandleList
Bases: openpyxl.descriptors.serialisable.Serialisable
class openpyxl.drawing.shapes.Backdrop(anchor=None, norm=None, up=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
anchor
Values must be of type <class ‘openpyxl.drawing.shapes.Point3D’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
norm
Values must be of type <class ‘openpyxl.drawing.shapes.Vector3D’>
up
Values must be of type <class ‘openpyxl.drawing.shapes.Vector3D’>
class openpyxl.drawing.shapes.Bevel(w=None, h=None, prst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
h
Values must be of type Values must be of type <class ‘int’>
prst
Values must be of type <openpyxl.descriptors.base.Set object at 0x7fd32b6e5898>
w
Values must be of type Values must be of type <class ‘int’>
class openpyxl.drawing.shapes.Camera(prst=None, fov=None, zoom=None, rot=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
fov
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
prst
Values must be of type <openpyxl.descriptors.base.Set object at 0x7fd32b6e5080>
rot
Values must be of type <class ‘openpyxl.drawing.shapes.SphereCoords’>
zoom
Values must be of type <class ‘openpyxl.descriptors.excel.Percentage’>
class openpyxl.drawing.shapes.ConnectionSite(ang=None, pos=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
ang
Values must be of type <class ‘float’>
pos
Values must be of type <class ‘openpyxl.drawing.shapes.AdjPoint2D’>
class openpyxl.drawing.shapes.ConnectionSiteList(cxn=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cxn
Values must be of type <class ‘openpyxl.drawing.shapes.ConnectionSite’>
class openpyxl.drawing.shapes.CustomGeometry2D(avLst=None, gdLst=None, ahLst=None,
cxnLst=None, rect=None, pathLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
ahLst
Values must be of type <class ‘openpyxl.drawing.shapes.AdjustHandleList’>
avLst
Values must be of type <class ‘openpyxl.drawing.shapes.GeomGuideList’>
cxnLst
Values must be of type <class ‘openpyxl.drawing.shapes.ConnectionSiteList’>
gdLst
Values must be of type <class ‘openpyxl.drawing.shapes.GeomGuideList’>
pathLst
Values must be of type <class ‘openpyxl.drawing.shapes.Path2DList’>
rect
Values must be of type <class ‘openpyxl.drawing.shapes.GeomRect’>
class openpyxl.drawing.shapes.FontReference(idx=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
idx
Value must be one of {‘minor’, ‘major’}
class openpyxl.drawing.shapes.GeomGuide(name=None, fmla=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
fmla
Values must be of type <class ‘str’>
name
Values must be of type <class ‘str’>
class openpyxl.drawing.shapes.GeomGuideList(gd=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
gd
Values must be of type <class ‘openpyxl.drawing.shapes.GeomGuide’>
class openpyxl.drawing.shapes.GeomRect(l=None, t=None, r=None, b=None)
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.shapes.LightRig(rig=None, dir=None, rot=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
dir
Values must be of type <openpyxl.descriptors.base.Set object at 0x7fd32b6e52b0>
rig
Values must be of type <openpyxl.descriptors.base.Set object at 0x7fd32b6e51d0>
rot
Values must be of type <class ‘openpyxl.drawing.shapes.SphereCoords’>
class openpyxl.drawing.shapes.Path2D(w=None, h=None, fill=None, stroke=None, extru-
sionOk=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
extrusionOk
Values must be of type <class ‘bool’>
fill
Value must be one of {‘darkenLess’, ‘norm’, ‘lightenLess’, ‘lighten’, ‘darken’}
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.shapes.Path2DList(path=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
path
Values must be of type <class ‘openpyxl.drawing.shapes.Path2D’>
class openpyxl.drawing.shapes.Point2D(x=None, y=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
x
Values must be of type <class ‘int’>
y
Values must be of type <class ‘int’>
class openpyxl.drawing.shapes.Point3D(x=None, y=None, z=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
x
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
y
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
z
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
class openpyxl.drawing.shapes.PositiveSize2D(cx=None, cy=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
Dimensions in EMUs
cx
Values must be of type <class ‘int’>
cy
Values must be of type <class ‘int’>
class openpyxl.drawing.shapes.PresetGeometry2D(prst=None, avLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
avLst
Values must be of type <class ‘openpyxl.drawing.shapes.GeomGuideList’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
prst
Value must be one of {‘flowChartOnlineStorage’, ‘gear6’, ‘bentUpArrow’, ‘bentConnector3’, ‘home-
Plate’, ‘callout2’, ‘flowChartManualOperation’, ‘borderCallout3’, ‘actionButtonBackPrevious’, ‘star8’,
‘round2SameRect’, ‘accentCallout3’, ‘leftUpArrow’, ‘decagon’, ‘corner’, ‘flowChartInputOutput’,
‘mathNotEqual’, ‘diamond’, ‘borderCallout1’, ‘actionButtonMovie’, ‘horizontalScroll’, ‘flowChart-
ManualInput’, ‘leftArrowCallout’, ‘callout3’, ‘star5’, ‘accentCallout1’, ‘star10’, ‘flowChartMagnetic-
Drum’, ‘actionButtonReturn’, ‘actionButtonSound’, ‘flowChartMultidocument’, ‘actionButtonHome’,
‘actionButtonEnd’, ‘mathEqual’, ‘stripedRightArrow’, ‘callout1’, ‘mathMultiply’, ‘flowChartInternal-
Storage’, ‘flowChartPunchedCard’, ‘ribbon2’, ‘actionButtonBlank’, ‘quadArrowCallout’, ‘bracePair’,
‘flowChartOfflineStorage’, ‘blockArc’, ‘curvedUpArrow’, ‘foldedCorner’, ‘heptagon’, ‘uturnArrow’,
‘hexagon’, ‘roundRect’, ‘flowChartPreparation’, ‘trapezoid’, ‘flowChartMagneticTape’, ‘donut’, ‘light-
ningBolt’, ‘star4’, ‘ellipseRibbon’, ‘irregularSeal1’, ‘octagon’, ‘triangle’, ‘doubleWave’, ‘noSmoking’,
‘mathPlus’, ‘wedgeRectCallout’, ‘accentBorderCallout2’, ‘upArrowCallout’, ‘pentagon’, ‘plaque’, ‘el-
lipse’, ‘borderCallout2’, ‘cornerTabs’, ‘pie’, ‘quadArrow’, ‘flowChartDocument’, ‘notchedRightArrow’,
‘teardrop’, ‘snip2DiagRect’, ‘star6’, ‘actionButtonBeginning’, ‘leftRightArrow’, ‘curvedRightArrow’,
‘accentCallout2’, ‘leftRightCircularArrow’, ‘leftRightUpArrow’, ‘round2DiagRect’, ‘moon’, ‘action-
ButtonDocument’, ‘parallelogram’, ‘cloudCallout’, ‘flowChartExtract’, ‘curvedConnector3’, ‘flowChart-
MagneticDisk’, ‘lineInv’, ‘irregularSeal2’, ‘curvedConnector4’, ‘line’, ‘flowChartSort’, ‘leftRightRib-
bon’, ‘diagStripe’, ‘rtTriangle’, ‘rect’, ‘star12’, ‘star16’, ‘flowChartOffpageConnector’, ‘chord’, ‘half-
Frame’, ‘wedgeRoundRectCallout’, ‘squareTabs’, ‘rightArrowCallout’, ‘gear9’, ‘upDownArrowCallout’,
‘ellipseRibbon2’, ‘snip2SameRect’, ‘flowChartPunchedTape’, ‘actionButtonInformation’, ‘flowChart-
Process’, ‘accentBorderCallout3’, ‘flowChartCollate’, ‘upDownArrow’, ‘rightArrow’, ‘circularArrow’,
‘flowChartMerge’, ‘bevel’, ‘wave’, ‘flowChartAlternateProcess’, ‘smileyFace’, ‘flowChartConnector’,
‘flowChartPredefinedProcess’, ‘curvedConnector5’, ‘bentArrow’, ‘curvedConnector2’, ‘can’, ‘flowChart-
Display’, ‘mathMinus’, ‘nonIsoscelesTrapezoid’, ‘mathDivide’, ‘arc’, ‘bentConnector4’, ‘snip1Rect’,
fillRef
Values must be of type <class ‘openpyxl.drawing.shapes.StyleMatrixReference’>
fontRef
Values must be of type <class ‘openpyxl.drawing.shapes.FontReference’>
lnRef
Values must be of type <class ‘openpyxl.drawing.shapes.StyleMatrixReference’>
class openpyxl.drawing.shapes.SphereCoords(lat=None, lon=None, rev=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
lat
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
lon
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
rev
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
class openpyxl.drawing.shapes.StyleMatrixReference(idx=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
idx
Values must be of type <class ‘int’>
class openpyxl.drawing.shapes.Transform2D(rot=None, flipH=None, flipV=None, off=None,
ext=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
ext
Values must be of type <class ‘openpyxl.drawing.shapes.PositiveSize2D’>
flipH
Values must be of type <class ‘bool’>
flipV
Values must be of type <class ‘bool’>
off
Values must be of type <class ‘openpyxl.drawing.shapes.Point2D’>
rot
Values must be of type <class ‘int’>
tagname = ‘xfrm’
class openpyxl.drawing.shapes.Vector3D(dx=None, dy=None, dz=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
dx
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
dy
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
dz
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
openpyxl.drawing.spreadsheet_drawing module
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.graphic.Connector’>
ext
Values must be of type <class ‘openpyxl.drawing.shapes.PositiveSize2D’>
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.graphic.PictureFrame’>
sp
Value must be one of {‘coneToMax’, ‘pyramid’, ‘pyramidToMax’, ‘cylinder’, ‘box’, ‘cone’}
tagname = ‘oneCellAnchor’
class openpyxl.drawing.spreadsheet_drawing.SpreadsheetDrawing(twoCellAnchor=(),
oneCellAnchor=(),
absoluteAnchor=())
Bases: openpyxl.descriptors.serialisable.Serialisable
absoluteAnchor
A sequence (list or tuple) that may only contain objects of the declared type
oneCellAnchor
A sequence (list or tuple) that may only contain objects of the declared type
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)
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.graphic.Connector’>
editAs
Value must be one of {‘oneCell’, ‘twoCell’, ‘absolute’}
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.graphic.PictureFrame’>
sp
Value must be one of {‘coneToMax’, ‘pyramid’, ‘pyramidToMax’, ‘cylinder’, ‘box’, ‘cone’}
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
startAt
Values must be of type <class ‘int’>
type
Value must be one of {‘arabicDbPlain’, ‘hindiAlpha1Period’, ‘ea1JpnKorPeriod’, ‘ea1ChsPlain’, ‘cir-
cleNumWdWhitePlain’, ‘thaiAlphaParenR’, ‘circleNumWdBlackPlain’, ‘ea1ChtPlain’, ‘thaiAlphaParen-
Both’, ‘alphaUcParenR’, ‘hebrew2Minus’, ‘romanUcPeriod’, ‘arabicDbPeriod’, ‘hindiAlphaPeriod’, ‘ara-
bicPlain’, ‘circleNumDbPlain’, ‘ea1JpnChsDbPeriod’, ‘thaiNumParenBoth’, ‘arabic2Minus’, ‘thaiAl-
phaPeriod’, ‘romanLcPeriod’, ‘arabicParenR’, ‘alphaLcParenR’, ‘romanUcParenR’, ‘ea1ChsPeriod’, ‘ara-
bicParenBoth’, ‘alphaLcPeriod’, ‘romanLcParenR’, ‘alphaUcParenBoth’, ‘ea1ChtPeriod’, ‘thaiNum-
ParenR’, ‘romanLcParenBoth’, ‘arabic1Minus’, ‘alphaLcParenBoth’, ‘romanUcParenBoth’, ‘alphaUcPe-
riod’, ‘arabicPeriod’, ‘thaiNumPeriod’, ‘hindiNumPeriod’, ‘hindiNumParenR’, ‘ea1JpnKorPlain’}
class openpyxl.drawing.text.CharacterProperties(kumimoji=None, lang=None, alt-
Lang=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, solid-
Fill=None, gradFill=None, blip-
Fill=None, pattFill=None, grpFill=None,
effectLst=None, effectDag=None, uL-
nTx=None, uLn=None, uFillTx=None,
uFill=None)
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 {‘noStrike’, ‘dblStrike’, ‘sngStrike’}
sym
Values must be of type <class ‘openpyxl.drawing.text.Font’>
sz
Values must be of type <class ‘int’>
tagname = ‘defRPr’
u
Value must be one of {‘wavy’, ‘wavyHeavy’, ‘words’, ‘wavyDbl’, ‘dotDotDashHeavy’, ‘dottedHeavy’,
‘heavy’, ‘dashLong’, ‘dashLongHeavy’, ‘dotDashHeavy’, ‘dashHeavy’, ‘dotted’, ‘dotDotDash’, ‘dash’,
‘sng’, ‘dotDash’, ‘dbl’}
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
name
Values must be of type <class ‘openpyxl.descriptors.base.String’>
class openpyxl.drawing.text.Font(typeface=None, panose=None, pitchFamily=None,
charset=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
charset
Values must be of type <class ‘openpyxl.descriptors.base.MinMax’>
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
panose
Values must be of type <class ‘openpyxl.descriptors.excel.HexBinary’>
pitchFamily
Values must be of type <class ‘openpyxl.descriptors.base.MinMax’>
tagname = ‘latin’
typeface
Values must be of type <class ‘str’>
class openpyxl.drawing.text.GeomGuide(name=None, fmla=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
fmla
Values must be of type Values must be of type <class ‘str’>
name
Values must be of type Values must be of type <class ‘str’>
class openpyxl.drawing.text.GeomGuideList(gd=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
gd
A sequence (list or tuple) that may only contain objects of the declared type
class openpyxl.drawing.text.Hyperlink(invalidUrl=None, action=None, tgtFrame=None,
tooltip=None, history=None, highlightClick=None,
endSnd=None, snd=None, extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
action
Values must be of type <class ‘openpyxl.descriptors.base.String’>
endSnd
Values must be of type <class ‘openpyxl.descriptors.base.Bool’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
highlightClick
Values must be of type <class ‘openpyxl.descriptors.base.Bool’>
history
Values must be of type <class ‘openpyxl.descriptors.base.Bool’>
invalidUrl
Values must be of type <class ‘openpyxl.descriptors.base.String’>
snd
Values must be of type <class ‘openpyxl.drawing.text.EmbeddedWAVAudioFile’>
tgtFrame
Values must be of type <class ‘openpyxl.descriptors.base.String’>
tooltip
Values must be of type <class ‘openpyxl.descriptors.base.String’>
class openpyxl.drawing.text.LineBreak(rPr=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
rPr
Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>
fontAlgn
Value must be one of {‘b’, ‘ctr’, ‘auto’, ‘base’, ‘t’}
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)
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 0x7fd32e0830f0>
class openpyxl.drawing.text.RegularTextRun(rPr=None, t=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
namespace = ‘http://schemas.openxmlformats.org/drawingml/2006/main’
rPr
Values must be of type <class ‘openpyxl.drawing.text.CharacterProperties’>
t
Values must be of type <class ‘str’>
tagname = ‘r’
rtlCol
Values must be of type <class ‘bool’>
scene3d
Values must be of type <class ‘openpyxl.drawing.shapes.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 {‘mongolianVert’, ‘eaVert’, ‘wordArtVertRtl’, ‘horz’, ‘vert270’, ‘vert’, ‘wor-
dArtVert’}
vertOverflow
Value must be one of {‘clip’, ‘ellipsis’, ‘overflow’}
wrap
Value must be one of {‘none’, ‘square’}
class openpyxl.drawing.text.Spacing(spcPct=None, spcPts=None)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
algn
Values must be of type <openpyxl.descriptors.base.Set object at 0x7fd32e076e80>
pos
Values must be of type <class ‘openpyxl.descriptors.base.Integer’>
class openpyxl.drawing.text.TabStopList(tab=None)
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)
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 ‘openpyxl.descriptors.base.String’>
type
Values must be of type <class ‘str’>
class openpyxl.drawing.text.TextNormalAutofit(fontScale=None, lnSpcReduction=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
fontScale
Values must be of type <class ‘int’>
lnSpcReduction
Values must be of type <class ‘int’>
openpyxl.formatting package
Submodules
openpyxl.formatting.formatting module
class openpyxl.formatting.formatting.ConditionalFormatting
Bases: object
Conditional formatting rules.
add(range_string, cfRule)
Add a rule such as ColorScaleRule, FormulaRule or CellIsRule
The priority will be added automatically.
setDxfStyles(wb)
update(cfRules)
openpyxl.formatting.formatting.unpack_rules(cfRules)
openpyxl.formatting.rule module
openpyxl.formatting.rule.CellIsRule(operator=None, formula=None, stopIfTrue=None,
font=None, border=None, fill=None)
Conditional formatting rule based on cell contents.
class openpyxl.formatting.rule.ColorScale(cfvo=None, color=None)
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)
Backwards compatibility
timePeriod
Value must be one of {‘yesterday’, ‘last7Days’, ‘tomorrow’, ‘nextMonth’, ‘lastWeek’, ‘nextWeek’, ‘last-
Month’, ‘thisMonth’, ‘thisWeek’, ‘today’}
type
Value must be one of {‘aboveAverage’, ‘dataBar’, ‘top10’, ‘cellIs’, ‘expression’, ‘notContainsBlanks’,
‘colorScale’, ‘uniqueValues’, ‘beginsWith’, ‘endsWith’, ‘iconSet’, ‘containsErrors’, ‘notContainsErrors’,
‘containsBlanks’, ‘containsText’, ‘timePeriod’, ‘duplicateValues’, ‘notContainsText’}
class openpyxl.formatting.rule.RuleType
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)
Bases: openpyxl.descriptors.base.Float
Expected type depends upon type attribue of parent :-(
openpyxl.packaging package
Submodules
openpyxl.packaging.manifest module
class openpyxl.packaging.manifest.FileExtension(Extension, ContentType)
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=())
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
extensions
filenames
tagname = ‘Types’
to_tree()
Custom serialisation method to allow setting a default namespace
class openpyxl.packaging.manifest.Override(PartName, ContentType)
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.manifest.write_content_types(workbook, as_template=False,
exts=None)
openpyxl.packaging.relationship module
class openpyxl.packaging.relationship.Relationship(type=None, target=None, target-
Mode=None, id=None, Id=None,
Type=None, Target=None)
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’>
tagname = ‘Relationship’
class openpyxl.packaging.relationship.RelationshipList(Relationship=())
Bases: openpyxl.descriptors.serialisable.Serialisable
Relationship
A sequence (list or tuple) that may only contain objects of the declared type
append(value)
tagname = ‘Relationships’
to_tree()
openpyxl.packaging.relationship.get_dependents(archive, filename)
Normalise dependency file paths to absolute ones
Relative paths are relative to parent object
openpyxl.reader package
Submodules
openpyxl.reader.excel module
openpyxl.reader.excel.load_workbook(filename, read_only=False, keep_vba=False,
data_only=False, guess_types=False)
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
Return type openpyxl.workbook.Workbook
openpyxl.reader.excel.repair_central_directory(zipFile, is_file_instance)
trims trailing data from the central directory code taken from http://stackoverflow.com/a/7457686/570216, cour-
tesy of Uri Cohen
openpyxl.reader.strings module
openpyxl.reader.strings.read_string_table(xml_source)
Read in all shared strings in the table
openpyxl.reader.style module
openpyxl.reader.workbook module
openpyxl.reader.workbook.read_content_types(archive)
Read content types.
openpyxl.reader.workbook.read_rels(archive)
Read relationships for a workbook
openpyxl.reader.workbook.read_sheets(archive)
Read worksheet titles and ids for a workbook
openpyxl.reader.worksheet module
class openpyxl.reader.worksheet.WorkSheetParser(wb, title, xml_source, shared_strings)
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()
parse_auto_filter(element)
parse_cell(element)
parse_column_dimensions(col)
parse_data_validation(element)
parse_extensions(element)
parse_header_footer(element)
parse_legacy_drawing(element)
parse_margins(element)
parse_merge(element)
parse_page_setup(element)
parse_print_options(element)
parse_properties(element)
parse_row_dimensions(row)
parse_sheet_protection(element)
parse_sheet_views(element)
parse_sort(element)
parser_conditional_formatting(element)
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, readin-
gOrder=0, text_rotation=None, wrap_text=None,
shrink_to_fit=None, mergeCell=None)
Bases: openpyxl.styles.hashable.HashableObject
Alignment options for use in styles.
horizontal
Value must be one of {‘center’, ‘general’, ‘right’, ‘centerContinuous’, ‘left’, ‘fill’, ‘justify’, ‘distributed’}
indent
Values must be of type <class ‘float’>
justifyLastLine
Values must be of type <class ‘bool’>
readingOrder
Values must be of type <class ‘float’>
relativeIndent
Values must be of type <class ‘float’>
shrinkToFit
Values must be of type <class ‘bool’>
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}
vertical
Value must be one of {‘justify’, ‘center’, ‘top’, ‘bottom’, ‘distributed’}
wrapText
Values must be of type <class ‘bool’>
openpyxl.styles.borders module
class openpyxl.styles.borders.Border(left=, right=, top=, bottom=, diagonal=, diago-
nal_direction=None, vertical=None, horizontal=None,
diagonalUp=False, diagonalDown=False, outline=True,
start=None, end=None)
Bases: openpyxl.styles.hashable.HashableObject
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)
Bases: openpyxl.styles.hashable.HashableObject
Border options for use in styles. Caution: if you do not specify a border_style, other attributes will have no
effect !
color
Values must be of type <class ‘openpyxl.styles.colors.Color’>
style
Value must be one of {‘dashed’, ‘thick’, ‘mediumDashed’, ‘thin’, ‘slantDashDot’, ‘mediumDashDotDot’,
‘dashDotDot’, ‘dashDot’, ‘medium’, ‘mediumDashDot’, ‘dotted’, ‘double’, ‘hair’}
openpyxl.styles.colors module
class openpyxl.styles.colors.Color(rgb=‘00000000’, indexed=None, auto=None, theme=None,
tint=0.0, index=None, type=’rgb’)
Bases: openpyxl.styles.hashable.HashableObject
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
openpyxl.styles.differential module
class openpyxl.styles.differential.DifferentialStyle(font=None, numFmt=None,
fill=None, alignment=None,
border=None, protection=None,
extLst=None)
Bases: openpyxl.styles.hashable.HashableObject
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’
openpyxl.styles.fills module
class openpyxl.styles.fills.Fill
Bases: openpyxl.styles.hashable.HashableObject
Base class
classmethod from_tree(el)
tagname = ‘fill’
class openpyxl.styles.fills.GradientFill(type=’linear’, degree=0, left=0, right=0, top=0, bot-
tom=0, stop=(), fill_type=None)
Bases: openpyxl.styles.fills.Fill
bottom
Values must be of type <class ‘float’>
degree
Values must be of type <class ‘float’>
left
Values must be of type <class ‘float’>
right
Values must be of type <class ‘float’>
stop
A sequence of primitive types that are stored as a single attribute. “val” is the default attribute
tagname = ‘gradientFill’
to_tree(tagname=None, namespace=None, idx=None)
top
Values must be of type <class ‘float’>
type
Value must be one of {‘path’, ‘linear’}
class openpyxl.styles.fills.PatternFill(patternType=None, fgColor=Color(indexed=Values
must be of type <class ‘int’>, auto=Values must be
of type <class ‘bool’>, theme=Values must be of
type <class ‘int’>), bgColor=Color(indexed=Values
must be of type <class ‘int’>, auto=Values must be
of type <class ‘bool’>, theme=Values must be of type
<class ‘int’>), fill_type=None, start_color=None,
end_color=None)
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’>
fgColor
Values must be of type <class ‘openpyxl.styles.colors.Color’>
patternType
Value must be one of {‘lightHorizontal’, ‘solid’, ‘darkTrellis’, ‘lightGray’, ‘darkGrid’, ‘gray125’,
‘lightUp’, ‘darkGray’, ‘darkVertical’, ‘lightVertical’, ‘gray0625’, ‘lightGrid’, ‘lightDown’, ‘lightTrellis’,
‘darkHorizontal’, ‘darkUp’, ‘mediumGray’, ‘darkDown’}
tagname = ‘patternFill’
to_tree(tagname=None, idx=None)
openpyxl.styles.fonts module
class openpyxl.styles.fonts.Font(name=’Calibri’, sz=11, b=False, i=False, charset=None,
u=None, strike=False, color=‘00000000’, scheme=None,
family=2, size=None, bold=None, italic=None,
strikethrough=None, underline=None, vertAlign=None, out-
line=False, shadow=False, condense=False, extend=False)
Bases: openpyxl.styles.hashable.HashableObject
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’>
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’>
name
Values must be of type <class ‘str’>
outline
Values must be of type <class ‘bool’>
scheme
Value must be one of {‘minor’, ‘major’}
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 = ‘font’
u
Value must be one of {‘single’, ‘doubleAccounting’, ‘double’, ‘singleAccounting’}
vertAlign
Value must be one of {‘superscript’, ‘subscript’, ‘baseline’}
openpyxl.styles.hashable module
class openpyxl.styles.hashable.HashableObject
Bases: openpyxl.descriptors.serialisable.Serialisable
Define how to hash property classes.
copy(**kwargs)
key
Use a tuple of fields as the basis for a key
openpyxl.styles.named_styles module
class openpyxl.styles.named_styles.NamedCellStyle(name=None, xfId=None, buil-
tinId=None, iLevel=None, hid-
den=None, customBuiltin=None,
extLst=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
Pointer-based representation of named styles in XML xfId refers to the corresponding CellStyleXf
builtinId
Values must be of type <class ‘int’>
customBuiltin
Values must be of type <class ‘bool’>
extLst
Values must be of type <class ‘openpyxl.descriptors.excel.ExtensionList’>
hidden
Values must be of type <class ‘bool’>
iLevel
Values must be of type <class ‘int’>
name
Values must be of type <class ‘str’>
tagname = ‘cellStyle’
xfId
Values must be of type <class ‘int’>
class openpyxl.styles.named_styles.NamedCellStyleList(count=None, cellStyle=())
Bases: openpyxl.descriptors.serialisable.Serialisable
cellStyle
A sequence (list or tuple) that may only contain objects of the declared type
count
names
Convert to NamedStyle objects and remove duplicates
tagname = ‘cellStyles’
class openpyxl.styles.named_styles.NamedStyle(name=’Normal’,
font=Font(color=Color(indexed=Values
must be of type <class ‘int’>, auto=Values
must be of type <class ‘bool’>, theme=Values
must be of type <class ‘int’>)), fill=, bor-
der=, alignment=, number_format=None,
protection=, builtinId=0, hidden=False)
Bases: openpyxl.styles.hashable.HashableObject
Named and editable styles
alignment
Values must be of type <class ‘openpyxl.styles.alignment.Alignment’>
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’>
number_format
Values must be of type <class ‘str’>
protection
Values must be of type <class ‘openpyxl.styles.protection.Protection’>
openpyxl.styles.numbers module
class openpyxl.styles.numbers.NumberFormat(numFmtId=None, formatCode=None)
Bases: openpyxl.styles.hashable.HashableObject
formatCode
Values must be of type <class ‘str’>
numFmtId
Values must be of type <class ‘int’>
class openpyxl.styles.numbers.NumberFormatDescriptor(*args, **kw)
Bases: openpyxl.descriptors.base.String
class openpyxl.styles.numbers.NumberFormatList(count=None, numFmt=())
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)
Return one of the standard format codes by index.
openpyxl.styles.numbers.builtin_format_id(fmt)
Return the id of a standard style.
openpyxl.styles.numbers.is_builtin(fmt)
openpyxl.styles.numbers.is_date_format(fmt)
openpyxl.styles.protection module
class openpyxl.styles.protection.Protection(locked=True, hidden=False)
Bases: openpyxl.styles.hashable.HashableObject
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)
Bases: object
Proxy formatting objects so that they cannot be altered
copy(**kw)
Return a copy of the proxied object. Keyword args will be passed through
openpyxl.styles.styleable module
class openpyxl.styles.styleable.NumberFormatDescriptor
Bases: object
collection = ‘_number_formats’
key = ‘numFmtId’
class openpyxl.styles.styleable.StyleDescriptor(collection, key)
Bases: object
class openpyxl.styles.styleable.StyleableObject(sheet, style_array=None)
Bases: object
Base class for styleble objects implementing proxy and lookup functions
has_style
parent
pivotButton
quotePrefix
style
style_id
openpyxl.utils package
openpyxl.utils.absolute_coordinate(coord_string)
Convert a coordinate to an absolute coordinate string (B12 -> $B$12)
openpyxl.utils.cols_from_range(range_string)
Get individual addresses for every cell in a range. Yields one row at a time.
openpyxl.utils.column_index_from_string(str_col)
Convert a column name into a numerical index (‘A’ -> 1)
openpyxl.utils.coordinate_from_string(coord_string)
Convert a coordinate string like ‘B12’ to a tuple (‘B’, 12)
openpyxl.utils.coordinate_to_tuple(coordinate)
Convert an Excel style coordinate to (row, colum) tuple
openpyxl.utils.get_column_interval(start, end)
openpyxl.utils.get_column_letter(idx)
Convert a column index into a column letter (3 -> ‘C’)
openpyxl.utils.quote_sheetname(sheetname)
openpyxl.utils.range_boundaries(range_string)
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.range_to_tuple(range_string)
Convert a worksheet range to the sheetname and maximum and minimum coordinate indices
openpyxl.utils.rows_from_range(range_string)
Get individual addresses for every cell in a range. Yields one row at a time.
Submodules
openpyxl.utils.bound_dictionary module
class openpyxl.utils.bound_dictionary.BoundDictionary(reference=None, *args, **kw)
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.datetime module
class openpyxl.utils.datetime.GMT
Bases: datetime.tzinfo
dst(dt)
tzname(dt)
utcoffset(dt)
openpyxl.utils.datetime.W3CDTF_to_datetime(formatted_string)
Convert from a timestamp string to a datetime object.
openpyxl.utils.datetime.datetime_to_W3CDTF(dt)
Convert from a datetime to a timestamp string.
openpyxl.utils.datetime.days_to_time(value)
openpyxl.utils.datetime.from_excel(value, offset=2415018.5)
openpyxl.utils.datetime.time_to_days(value)
Convert a time value to fractions of day
openpyxl.utils.datetime.timedelta_to_days(value)
Convert a timedelta value to fractions of a day
openpyxl.utils.datetime.to_excel(dt, offset=2415018.5)
openpyxl.utils.exceptions module
exception openpyxl.utils.exceptions.CellCoordinatesException
Bases: Exception
Error for converting between numeric and A1-style cell references.
exception openpyxl.utils.exceptions.IllegalCharacterError
Bases: Exception
The data submitted which cannot be used directly in Excel files. It must be removed or escaped.
exception openpyxl.utils.exceptions.InsufficientCoordinatesException
Bases: Exception
Error for partially specified cell coordinates.
exception openpyxl.utils.exceptions.InvalidFileException
Bases: Exception
Error for trying to open a non-ooxml file.
exception openpyxl.utils.exceptions.NamedRangeException
Bases: Exception
Error for badly formatted named ranges.
exception openpyxl.utils.exceptions.ReadOnlyWorkbookException
Bases: Exception
Error for trying to modify a read-only workbook
exception openpyxl.utils.exceptions.SheetTitleException
Bases: Exception
Error for bad sheet names.
exception openpyxl.utils.exceptions.WorkbookAlreadySaved
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)
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)
append(value)
index(value)
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)
openpyxl.utils.units.EMU_to_inch(value)
openpyxl.utils.units.EMU_to_pixels(value)
openpyxl.utils.units.angle_to_degrees(value)
openpyxl.utils.units.cm_to_EMU(value)
1 cm = 360000 EMUs
openpyxl.utils.units.cm_to_dxa(value)
openpyxl.utils.units.degrees_to_angle(value)
1 degree = 60000 angles
openpyxl.utils.units.dxa_to_cm(value)
openpyxl.utils.units.dxa_to_inch(value)
openpyxl.utils.units.inch_to_EMU(value)
1 inch = 914400 EMUs
openpyxl.utils.units.inch_to_dxa(value)
1 inch = 72 * 20 dxa
openpyxl.utils.units.pixels_to_EMU(value)
1 pixel = 9525 EMUs
openpyxl.utils.units.pixels_to_points(value, dpi=96)
96 dpi, 72i
openpyxl.utils.units.points_to_pixels(value, dpi=96)
openpyxl.utils.units.short_color(color)
format a color to its short size
openpyxl.workbook package
Subpackages
openpyxl.workbook.names package
Submodules
openpyxl.workbook.names.external module
class openpyxl.workbook.names.external.ExternalBook(Id, Target, TargetMode=None,
Type=None)
Bases: openpyxl.descriptors.Strict
Map the relationship of one workbook to another
Id
Values must be of type <class ‘str’>
Target
Values must be of type <class ‘str’>
TargetMode = ‘External’
Type = ‘http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath’
class openpyxl.workbook.names.external.ExternalRange(name, refersTo=None,
sheetId=None)
Bases: openpyxl.descriptors.Strict
Map external named ranges NB. the specification for these is different to named ranges within a workbook See
18.14.5
name
Values must be of type <class ‘str’>
refersTo
Values must be of type <class ‘str’>
sheetId
Values must be of type <class ‘str’>
openpyxl.workbook.names.external.detect_external_links(rels, archive)
openpyxl.workbook.names.external.parse_books(xml)
openpyxl.workbook.names.external.parse_ranges(xml)
openpyxl.workbook.names.external.write_external_book_rel(book)
Serialise link to external file
openpyxl.workbook.names.external.write_external_link(links)
Serialise links to ranges in a single external worbook
openpyxl.workbook.names.named_range module
class openpyxl.workbook.names.named_range.NamedRange(name, destinations, scope=None)
Bases: openpyxl.workbook.names.named_range.NamedValue
A named group of cells
Scope is a worksheet object or None for workbook scope names (the default)
destinations
name
repr_format = ‘<%s “%s”>’
scope
str_format = ‘%s!%s’
value
openpyxl.workbook.names.named_range.NamedRangeContainingValue
alias of NamedValue
class openpyxl.workbook.names.named_range.NamedValue(name, value)
Bases: object
A named value
localSheetId
name
scope
value
openpyxl.workbook.names.named_range.external_range(range_string)
openpyxl.workbook.names.named_range.read_named_ranges(xml_source, workbook)
Read named ranges, excluding poorly defined ranges.
openpyxl.workbook.names.named_range.refers_to_range(range_string)
openpyxl.workbook.names.named_range.split_named_range(range_string)
Separate a named range into its component parts
Submodules
openpyxl.workbook.child module
openpyxl.workbook.child.avoid_duplicate_name(names, value)
Naive check to see whether name already exists. If name does exist suggest a name using an incrementer
openpyxl.workbook.properties module
class openpyxl.workbook.properties.CalcProperties(calcId=122211, calcMode=’auto’,
fullCalcOnLoad=True, refMode=’A1’,
iterate=False, iterateCount=None, it-
erateDelta=None, fullPrecision=None,
calcCompleted=True, calcOn-
Save=True, concurrentCalc=True,
concurrentManualCount=None, force-
FullCalc=None)
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 {‘A1’, ‘R1C1’}
tagname = ‘calcPr’
class openpyxl.workbook.properties.FileVersion(appName=None, lastEdited=None, low-
estEdited=None, rupBuild=None, code-
Name=None)
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’
showBorderUnselectedTables
Values must be of type <class ‘bool’>
showInkAnnotation
Values must be of type <class ‘bool’>
showObjects
Value must be one of {‘all’, ‘placeholders’}
showPivotChartFilter
Values must be of type <class ‘bool’>
tagname = ‘workbookPr’
updateLinks
Value must be one of {‘userSet’, ‘never’, ‘always’}
openpyxl.workbook.workbook module
class openpyxl.workbook.workbook.Workbook(write_only=False)
Bases: object
Workbook is the container for all other parts of the document.
active
Get the currently active sheet
add_named_range(named_range)
Add an existing named_range to the list of named_ranges.
chartsheets
create_chartsheet(title=None, index=None)
create_named_range(name, worksheet, range, scope=None)
Create a new named_range on a worksheet
create_sheet(title=None, index=None)
Create a worksheet (at an optional index).
Parameters
• title – optional title of the sheet
• index (int) – optional position at which the sheet will be inserted
data_only
get_active_sheet()
Returns the current active sheet.
get_index(worksheet)
Return the index of the worksheet.
get_named_range(name)
Return the range specified by name.
get_named_ranges()
Return all named ranges
get_sheet_by_name(name)
Returns a worksheet by its name.
Parameters name (string) – the name of the worksheet to look for
get_sheet_names()
read_only
remove_named_range(named_range)
Remove a named_range from this workbook.
remove_sheet(worksheet)
Remove a worksheet from this workbook.
save(filename)
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 the workbook.
Names are returned in the worksheets order.
Return type list of strings
worksheets
write_only
openpyxl.worksheet package
openpyxl.worksheet.isgenerator(obj)
Submodules
openpyxl.worksheet.datavalidation module
class openpyxl.worksheet.datavalidation.DataValidation(type=None, formula1=None,
formula2=None, al-
low_blank=False, showEr-
rorMessage=True, showIn-
putMessage=True, show-
DropDown=None, allow-
Blank=None, sqref=None,
promptTitle=None, er-
rorStyle=None, error=None,
prompt=None, errorTi-
tle=None, imeMode=None,
operator=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
add(cell)
Adds a openpyxl.cell to this validator
allowBlank
Values must be of type <class ‘bool’>
allow_blank
Values must be of type <class ‘bool’>
error
Values must be of type <class ‘str’>
errorStyle
Value must be one of {‘warning’, ‘stop’, ‘information’}
errorTitle
Values must be of type <class ‘str’>
formula1
Values must be of type <class ‘str’>
formula2
Values must be of type <class ‘str’>
imeMode
Value must be one of {‘fullKatakana’, ‘halfKatakana’, ‘noControl’, ‘hiragana’, ‘off’, ‘disabled’, ‘on’,
‘halfAlpha’, ‘fullAlpha’, ‘fullHangul’, ‘halfHangul’}
operator
Value must be one of {‘notEqual’, ‘between’, ‘greaterThan’, ‘lessThanOrEqual’, ‘notBetween’,
‘greaterThanOrEqual’, ‘lessThan’, ‘equal’}
prompt
Values must be of type <class ‘str’>
promptTitle
Values must be of type <class ‘str’>
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
tagname = ‘dataValidation’
type
Value must be one of {‘decimal’, ‘list’, ‘custom’, ‘time’, ‘date’, ‘textLength’, ‘whole’}
class openpyxl.worksheet.datavalidation.DataValidationList(disablePrompts=None,
xWindow=None, yWin-
dow=None, count=None,
dataValidation=())
Bases: openpyxl.descriptors.serialisable.Serialisable
append(dv)
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’
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=())
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). More work
to come.
openpyxl.worksheet.datavalidation.expand_cell_ranges(range_string)
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, out-
lineLevel=0, outline_level=None,
collapsed=False, style=None,
min=None, max=None, cus-
tomWidth=False, visible=None,
auto_size=None)
Bases: openpyxl.worksheet.dimensions.Dimension
Information about the display properties of a column.
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’>
width
Values must be of type <class ‘float’>
class openpyxl.worksheet.dimensions.Dimension(index, hidden, outlineLevel, collapsed, work-
sheet, visible=True, style=None)
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’>
visible
class openpyxl.worksheet.dimensions.DimensionHolder(worksheet, reference=’index’, de-
fault_factory=None)
Bases: openpyxl.utils.bound_dictionary.BoundDictionary
Allow columns to be grouped
group(start, end=None, outline_level=1, hidden=False)
allow grouping a range of consecutive columns together
Parameters
• start – first column to be grouped (mandatory)
• end – last column to be grouped (optional, default to start)
• outline_level – outline level
• hidden – should the group be hidden on workbook open or not
class openpyxl.worksheet.dimensions.RowDimension(worksheet, index=0, ht=None, cus-
tomHeight=None, s=None, custom-
Format=None, hidden=False, out-
lineLevel=0, outline_level=None,
collapsed=False, visible=None,
height=None, r=None, spans=None,
thickBot=None, thickTop=None, **kw)
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
ht
Values must be of type <class ‘float’>
thickBot
Values must be of type <class ‘bool’>
thickTop
Values must be of type <class ‘bool’>
openpyxl.worksheet.drawing module
class openpyxl.worksheet.drawing.Drawing(id=None)
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
allow_none = True
expected_type
alias of str
pattern = ‘\n[$]?(?P<min_col>[A-Z]+)\n[$]?(?P<min_row>\\d+)\n(:[$]?(?P<max_col>[A-Z]+)\n[$]?(?P<max_row>\\d+)
class openpyxl.worksheet.filters.ColorFilter(dxfId=None, cellColor=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
cellColor
Values must be of type <class ‘bool’>
dxfId
Values must be of type <class ‘int’>
class openpyxl.worksheet.filters.CustomFilter(operator=None, val=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
operator
Value must be one of {‘notEqual’, ‘greaterThan’, ‘lessThanOrEqual’, ‘greaterThanOrEqual’, ‘lessThan’,
‘equal’}
val
Values must be of type <class ‘str’>
class openpyxl.worksheet.filters.CustomFilters(_and=None, customFilter=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
customFilter
Values must be of type <class ‘openpyxl.worksheet.filters.CustomFilter’>
class openpyxl.worksheet.filters.DateGroupItem(year=None, month=None, day=None,
hour=None, minute=None, second=None,
dateTimeGrouping=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
dateTimeGrouping
Value must be one of {‘second’, ‘hour’, ‘year’, ‘minute’, ‘month’, ‘day’}
day
Values must be of type <class ‘int’>
hour
Values must be of type <class ‘int’>
minute
Values must be of type <class ‘int’>
month
Values must be of type <class ‘int’>
second
Values must be of type <class ‘int’>
year
Values must be of type <class ‘int’>
class openpyxl.worksheet.filters.DynamicFilter(type=None, val=None, valIso=None, max-
Val=None, maxValIso=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
maxVal
Values must be of type <class ‘float’>
maxValIso
Values must be of type <class ‘datetime.datetime’>
type
Value must be one of {‘M10’, ‘yesterday’, ‘tomorrow’, ‘nextMonth’, ‘null’, ‘M12’, ‘nextWeek’, ‘nex-
tYear’, ‘today’, ‘lastYear’, ‘lastWeek’, ‘M3’, ‘M11’, ‘lastQuarter’, ‘lastMonth’, ‘Q4’, ‘thisYear’, ‘Q2’,
‘M6’, ‘M2’, ‘belowAverage’, ‘M4’, ‘Q3’, ‘yearToDate’, ‘M5’, ‘M9’, ‘thisQuarter’, ‘M1’, ‘M8’, ‘aboveAv-
erage’, ‘Q1’, ‘M7’, ‘thisMonth’, ‘thisWeek’, ‘nextQuarter’}
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, show-
Button=None, filters=None, top10=None,
customFilters=None, dynamicFilter=None,
colorFilter=None, iconFilter=None,
extLst=None, blank=None, vals=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
colId
Values must be of type <class ‘int’>
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=(), date-
GroupItem=())
Bases: openpyxl.descriptors.serialisable.Serialisable
blank
Values must be of type <class ‘bool’>
calendarType
Value must be one of {‘gregorianMeFrench’, ‘japan’, ‘gregorianArabic’, ‘gregorianXlitEnglish’, ‘taiwan’,
‘gregorianUs’, ‘gregorian’, ‘korea’, ‘saka’, ‘gregorianXlitFrench’, ‘hijri’, ‘thai’, ‘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
class openpyxl.worksheet.filters.IconFilter(iconSet=None, iconId=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
iconId
Values must be of type <class ‘int’>
iconSet
Value must be one of {‘3TrafficLights1’, ‘5Quarters’, ‘4RedToBlack’, ‘3Symbols2’, ‘4Arrows’, ‘3Sym-
bols’, ‘3TrafficLights2’, ‘4Rating’, ‘5Rating’, ‘3Arrows’, ‘5Arrows’, ‘3ArrowsGray’, ‘3Flags’, ‘4Traffi-
cLights’, ‘5ArrowsGray’, ‘4ArrowsGray’, ‘3Signs’}
class openpyxl.worksheet.filters.SortCondition(ref=None, descending=None,
sortBy=None, customList=None, dx-
fId=None, iconSet=None, iconId=None)
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 {‘3TrafficLights1’, ‘5Quarters’, ‘4RedToBlack’, ‘3Symbols2’, ‘4Arrows’, ‘3Sym-
bols’, ‘3TrafficLights2’, ‘4Rating’, ‘5Rating’, ‘3Arrows’, ‘5Arrows’, ‘3ArrowsGray’, ‘3Flags’, ‘4Traffi-
cLights’, ‘5ArrowsGray’, ‘4ArrowsGray’, ‘3Signs’}
ref
Values must be of type <class ‘str’>
sortBy
Value must be one of {‘value’, ‘icon’, ‘cellColor’, ‘fontColor’}
tagname = ‘sortCondition’
class openpyxl.worksheet.filters.SortState(columnSort=None, caseSensitive=None, sort-
Method=None, ref=None, sortCondition=(),
extLst=None)
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
Values must be of type <class ‘str’>
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)
Bases: openpyxl.descriptors.serialisable.Serialisable
filterVal
Values must be of type <class ‘float’>
percent
Values must be of type <class ‘bool’>
top
Values must be of type <class ‘bool’>
val
Values must be of type <class ‘float’>
openpyxl.worksheet.header_footer module
class openpyxl.worksheet.header_footer.HeaderFooter
Bases: object
CENTER = ‘C’
LEFT = ‘L’
REPLACE_LIST = ((‘\n’, ‘_x000D_’), (‘&[Page]’, ‘&P’), (‘&[Pages]’, ‘&N’), (‘&[Date]’, ‘&D’), (‘&[Time]’, ‘&T’), (‘&[Pa
RIGHT = ‘R’
font_color
font_name
font_size
get()
has()
set(text)
Convert a compound string into attributes # incomplete because formatting commands can be nested
text
type
openpyxl.worksheet.hyperlink module
class openpyxl.worksheet.hyperlink.Hyperlink(ref=None, location=None, tooltip=None, dis-
play=None, id=None, target=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
display
Values must be of type <class ‘str’>
id
Values must be of type <class ‘str’>
location
Values must be of type <class ‘str’>
ref
Values must be of type <class ‘str’>
tagname = ‘hyperlink’
target
Values must be of type <class ‘str’>
tooltip
Values must be of type <class ‘str’>
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)
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, verticalCen-
tered=None, headings=None, gridLines=None,
gridLinesSet=None)
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’>
tag = ‘{http://schemas.openxmlformats.org/spreadsheetml/2006/main}printOptions’
tagname = ‘printOptions’
verticalCentered
Values must be of type <class ‘bool’>
class openpyxl.worksheet.page.PrintPageSetup(worksheet=None, orientation=None, paper-
Size=None, scale=None, fitToHeight=None,
fitToWidth=None, firstPageNumber=None,
useFirstPageNumber=None, paper-
Height=None, paperWidth=None, pa-
geOrder=None, usePrinterDefaults=None,
blackAndWhite=None, draft=None, cell-
Comments=None, errors=None, hor-
izontalDpi=None, verticalDpi=None,
copies=None, id=None)
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 {‘displayed’, ‘blank’, ‘dash’, ‘NA’}
firstPageNumber
Values must be of type <class ‘int’>
fitToHeight
Values must be of type <class ‘int’>
fitToPage
fitToWidth
Values must be of type <class ‘int’>
classmethod from_tree(node)
horizontalCentered()
horizontalDpi
Values must be of type <class ‘int’>
id
Values must be of type <class ‘str’>
options()
orientation
Value must be one of {‘default’, ‘portrait’, ‘landscape’}
pageOrder
Value must be one of {‘downThenOver’, ‘overThenDown’}
paperHeight
paperSize
Values must be of type <class ‘int’>
paperWidth
scale
Values must be of type <class ‘int’>
setup()
sheet_properties
Proxy property
tagname = ‘pageSetup’
to_tree()
useFirstPageNumber
Values must be of type <class ‘bool’>
usePrinterDefaults
Values must be of type <class ‘bool’>
verticalCentered()
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)
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=[])
Bases: openpyxl.descriptors.serialisable.Serialisable
append(brk=None)
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, sum-
maryRight=None, showOutlineSymbols=None)
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’>
tag = ‘{http://schemas.openxmlformats.org/spreadsheetml/2006/main}outlinePr’
tagname = ‘outlinePr’
class openpyxl.worksheet.properties.PageSetupProperties(autoPageBreaks=None,
fitToPage=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
autoPageBreaks
Values must be of type <class ‘bool’>
fitToPage
Values must be of type <class ‘bool’>
tag = ‘{http://schemas.openxmlformats.org/spreadsheetml/2006/main}pageSetUpPr’
tagname = ‘pageSetUpPr’
class openpyxl.worksheet.properties.WorksheetProperties(codeName=None, enable-
FormatConditionsCalcula-
tion=None, filterMode=None,
published=None, syncHori-
zontal=None, syncRef=None,
syncVertical=None, tran-
sitionEvaluation=None,
transitionEntry=None,
tabColor=None, out-
linePr=None, pageSe-
tUpPr=None)
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’>
tag = ‘{http://schemas.openxmlformats.org/spreadsheetml/2006/main}sheetPr’
tagname = ‘sheetPr’
transitionEntry
Elements
transitionEvaluation
Values must be of type <class ‘bool’>
openpyxl.worksheet.protection module
saltValue
Values must be of type <class ‘str’>
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)
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.protection.hash_password(plaintext_password=’‘)
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 <[email protected]>. See also
http://blogs.msdn.com/b/ericwhite/archive/2008/02/23/the-legacy-hashing-algorithm-in-open-xml.aspx
openpyxl.worksheet.read_only module
class openpyxl.worksheet.read_only.ReadOnlyWorksheet(parent_workbook, title, work-
sheet_path, xml_source,
shared_strings)
Bases: openpyxl.worksheet.worksheet.Worksheet
calculate_dimension(force=False)
columns
get_squared_range(min_col, min_row, max_col, max_row)
The source worksheet file may have columns or rows missing. Missing cells will be created.
max_column
max_row
min_column
min_row
rows
xml_source
Parse xml source on demand, default to Excel archive
openpyxl.worksheet.read_only.read_dimension(source)
openpyxl.worksheet.related module
class openpyxl.worksheet.related.Related(id=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
id
Values must be of type <class ‘str’>
to_tree(tagname)
openpyxl.worksheet.views module
class openpyxl.worksheet.views.Pane(xSplit=None, ySplit=None, topLeftCell=None, ac-
tivePane=’topLeft’, state=’split’)
Bases: openpyxl.descriptors.serialisable.Serialisable
activePane
Value must be one of {‘topLeft’, ‘bottomRight’, ‘bottomLeft’, ‘topRight’}
state
Value must be one of {‘frozenSplit’, ‘frozen’, ‘split’}
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’)
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 {‘topLeft’, ‘bottomRight’, ‘bottomLeft’, ‘topRight’}
sqref
Values must be of type <class ‘str’>
class openpyxl.worksheet.views.SheetView(windowProtection=None, showFormulas=None,
showGridLines=True, showRowColHeaders=None,
showZeros=None, rightToLeft=None, tabSe-
lected=None, showRuler=None, showOutli-
neSymbols=None, defaultGridColor=None,
showWhiteSpace=None, view=None, topLeft-
Cell=None, colorId=None, zoomScale=None,
zoomScaleNormal=None, zoomScaleSheetLay-
outView=None, zoomScalePageLayoutView=None,
workbookViewId=0, selection=None, pane=None)
Bases: openpyxl.descriptors.serialisable.Serialisable
Information about the visible portions of this sheet.
colorId
Values must be of type <class ‘int’>
defaultGridColor
Values must be of type <class ‘bool’>
pane
Values must be of type <class ‘openpyxl.worksheet.views.Pane’>
rightToLeft
Values must be of type <class ‘bool’>
selection
A sequence (list or tuple) that may only contain objects of the declared type
showFormulas
Values must be of type <class ‘bool’>
showGridLines
Values must be of type <class ‘bool’>
showOutlineSymbols
Values must be of type <class ‘bool’>
showRowColHeaders
Values must be of type <class ‘bool’>
showRuler
Values must be of type <class ‘bool’>
showWhiteSpace
Values must be of type <class ‘bool’>
showZeros
Values must be of type <class ‘bool’>
tabSelected
Values must be of type <class ‘bool’>
tagname = ‘sheetView’
topLeftCell
Values must be of type <class ‘str’>
view
Value must be one of {‘normal’, ‘pageBreakPreview’, ‘pageLayout’}
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’>
openpyxl.worksheet.worksheet module
class openpyxl.worksheet.worksheet.Worksheet(parent, title=None)
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_LEGAL = ‘5’
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)
Add a chart to the sheet Optionally provide a cell for the top-left anchor
add_data_validation(data_validation)
Add a data-validation object to the sheet. The data-validation object defines the type of data-validation to
be applied and the cell or range of cells it should apply to.
add_image(img, anchor=None)
Add an image to the sheet. Optionally provide a cell for the top-left anchor
add_print_title(n, rows_or_cols=’rows’)
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
append(iterable)
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)
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’})
calculate_dimension()
Return the minimum bounding range for all cells containing data.
cell(coordinate=None, row=None, column=None, value=None)
Returns a cell object based on the given coordinates.
Usage: cell(coodinate=’A15’) or cell(row=15, column=1)
If coordinates are not given, then row and column must be given.
Cells are kept in a dictionary which is empty at the worksheet creation. Calling cell creates the cell in
memory when they are first accessed, to reduce memory usage.
Parameters
• coordinate (string) – coordinates of the cell (e.g. ‘B12’)
• row (int) – row index of the cell (e.g. 4)
• column (int) – column index of the cell (e.g. 3)
Raise InsufficientCoordinatesException when coordinate or (row and column) are not given
Return type :class:openpyxl.cell.Cell
columns
Iterate over all columns in the worksheet
dimensions
freeze_panes
get_cell_collection()
Return an unordered list of the cells in this worksheet.
get_named_range(range_string)
Returns a 2D array of cells, with optional row and column offsets.
Parameters range_string (string) – named range name
Return type tuples of tuples of openpyxl.cell.Cell
get_squared_range(min_col, min_row, max_col, max_row)
Returns a 2D array of cells
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) – smallest row index (1-based index)
openpyxl.writer package
Submodules
openpyxl.writer.etree_worksheet module
openpyxl.writer.etree_worksheet.get_rows_to_write(worksheet)
Return all rows, and any cells that they contain
openpyxl.writer.etree_worksheet.write_cell(worksheet, cell, styled=None)
openpyxl.writer.etree_worksheet.write_rows(xf, worksheet)
Write worksheet data to xml.
openpyxl.writer.excel module
class openpyxl.writer.excel.ExcelWriter(workbook)
Bases: object
Write a workbook object to an Excel file.
comment_writer
alias of CommentWriter
save(filename, as_template=False)
Write data into the archive.
write_data(archive, as_template=False)
Write the various xml files into the zip archive.
openpyxl.writer.excel.save_virtual_workbook(workbook, as_template=False)
Return an in-memory workbook, suitable for a Django response.
openpyxl.writer.excel.save_workbook(workbook, filename, as_template=False)
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.lxml_worksheet module
openpyxl.writer.lxml_worksheet.write_cell(xf, worksheet, cell, styled=False)
openpyxl.writer.lxml_worksheet.write_rows(xf, worksheet)
Write worksheet data to xml.
openpyxl.writer.relations module
openpyxl.writer.relations.write_rels(worksheet, comments_id=None,
vba_controls_id=None)
Write relationships for the worksheet to xml.
openpyxl.writer.strings module
openpyxl.writer.strings.write_string_table(string_table)
Write the string table xml.
openpyxl.writer.styles module
openpyxl.writer.theme module
openpyxl.writer.theme.write_theme()
Write the theme xml.
openpyxl.writer.workbook module
openpyxl.writer.workbook.write_properties_app(workbook)
Write the properties xml.
openpyxl.writer.workbook.write_root_rels(workbook)
Write the relationships xml.
openpyxl.writer.workbook.write_workbook(workbook)
Write the core workbook xml.
openpyxl.writer.workbook.write_workbook_rels(workbook)
Write the workbook relationships xml.
openpyxl.writer.worksheet module
openpyxl.writer.worksheet.write_cols(worksheet)
Write worksheet columns to xml.
<cols> may never be empty - spec says must contain at least one child
openpyxl.writer.worksheet.write_conditional_formatting(worksheet)
Write conditional formatting to xml.
openpyxl.writer.worksheet.write_drawing(worksheet)
Add link to drawing if required
openpyxl.writer.worksheet.write_format(worksheet)
openpyxl.writer.worksheet.write_header_footer(worksheet)
openpyxl.writer.worksheet.write_hyperlinks(worksheet)
Write worksheet hyperlinks to xml.
openpyxl.writer.worksheet.write_mergecells(worksheet)
Write merged cells to xml.
openpyxl.writer.worksheet.write_worksheet(worksheet, shared_strings)
Write a worksheet to an xml file.
openpyxl.writer.write_only module
openpyxl.writer.write_only.WriteOnlyCell(ws=None, value=None)
class openpyxl.writer.write_only.WriteOnlyWorksheet(parent_workbook, title)
Bases: openpyxl.worksheet.worksheet.Worksheet
Streaming worksheet using lxml 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)
Parameters row (iterable) – iterable containing values to append
cell(*args, **kw)
close()
filename
merge_cells(*args, **kw)
range(*args, **kw)
writer = None
openpyxl.writer.write_only.create_temporary_file(suffix=’‘)
openpyxl.writer.write_only.isgenerator(obj)
openpyxl.writer.write_only.removed_method(*args, **kw)
openpyxl.writer.write_only.save_dump(workbook, filename)
openpyxl.xml package
openpyxl.xml.lxml_available()
openpyxl.xml.lxml_env_set()
Submodules
openpyxl.xml.constants module
openpyxl.xml.functions module
openpyxl.xml.functions.ConditionalElement(node, tag, condition, attr=None)
Utility function for adding nodes if certain criteria are fulfilled An optional attribute can be passed in which will
always be serialised as ‘1’
openpyxl.xml.functions.iterparse(source, *args, **kw)
openpyxl.xml.functions.localname(node)
openpyxl.xml.functions.safe_iterator(node, tag=None)
Return an iterator that is compatible with Python 2.6
openpyxl.xml.functions.safe_iterparse(source, *args, **kw)
openpyxl.xml.namespace module
• genindex
• modindex
• search
217
openpyxl Documentation, Release 2.4.0
Release Notes
11.1.2 Deprecations
219
openpyxl Documentation, Release 2.4.0
• 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
• #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
• 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.)
• Allow cells to be appended to standard worksheets for code compatibility with write-only mode.
• PR 31 Correct tutorial
• PR 32 See #380
• PR 37 Bind worksheet to ColumnDimension objects
• Updated docs
11.27.2 Bugfixes
11.29.1 Bugfixes
• #246
11.33.1 Compatibility
• 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
Drops support for Python < 2.5 and last version to support Python 2.5
11.34.2 Compatibility
• #109
• #165
• #179
• #209
• #112
• #166
• #109
• #223
• #124
• #157
11.34.5 Miscellaneous
o openpyxl.chartsheet.publish, 118
openpyxl, 3 openpyxl.chartsheet.relation, 119
openpyxl.cell, 77 openpyxl.chartsheet.tests, 114
openpyxl.cell.cell, 77 openpyxl.chartsheet.tests.test_chartsheet,
openpyxl.cell.interface, 78 114
openpyxl.cell.read_only, 79 openpyxl.chartsheet.tests.test_custom,
openpyxl.cell.text, 79 114
openpyxl.chart, 81 openpyxl.chartsheet.tests.test_properties,
openpyxl.chart.area_chart, 81 114
openpyxl.chart.axis, 82 openpyxl.chartsheet.tests.test_protection,
openpyxl.chart.bar_chart, 88 115
openpyxl.chart.bubble_chart, 89 openpyxl.chartsheet.tests.test_publish,
openpyxl.chart.chartspace, 90 115
openpyxl.chart.data_source, 95 openpyxl.chartsheet.tests.test_relation,
openpyxl.chart.descriptors, 96 115
openpyxl.chart.error_bar, 97 openpyxl.chartsheet.tests.test_views,
openpyxl.chart.label, 97 115
openpyxl.chart.layout, 99 openpyxl.chartsheet.views, 120
openpyxl.chart.legend, 100 openpyxl.comments, 120
openpyxl.chart.line_chart, 100 openpyxl.comments.author, 120
openpyxl.chart.marker, 102 openpyxl.comments.comments, 121
openpyxl.chart.picture, 103 openpyxl.comments.properties, 121
openpyxl.chart.pie_chart, 103 openpyxl.comments.reader, 122
openpyxl.chart.radar_chart, 105 openpyxl.comments.writer, 123
openpyxl.chart.reference, 105 openpyxl.descriptors, 123
openpyxl.chart.scatter_chart, 106 openpyxl.descriptors.base, 123
openpyxl.chart.series, 106 openpyxl.descriptors.excel, 125
openpyxl.chart.series_factory, 109 openpyxl.descriptors.namespace, 126
openpyxl.chart.shapes, 109 openpyxl.descriptors.nested, 126
openpyxl.chart.stock_chart, 110 openpyxl.descriptors.sequence, 127
openpyxl.chart.surface_chart, 110 openpyxl.descriptors.serialisable, 127
openpyxl.chart.text, 111 openpyxl.drawing, 128
openpyxl.chart.title, 112 openpyxl.drawing.colors, 128
openpyxl.chart.trendline, 112 openpyxl.drawing.drawing, 132
openpyxl.chart.updown_bars, 113 openpyxl.drawing.effect, 132
openpyxl.chartsheet, 114 openpyxl.drawing.fill, 139
openpyxl.chartsheet.chartsheet, 116 openpyxl.drawing.graphic, 144
openpyxl.chartsheet.custom, 116 openpyxl.drawing.image, 150
openpyxl.chartsheet.properties, 117 openpyxl.drawing.line, 150
openpyxl.chartsheet.protection, 117 openpyxl.drawing.shape, 152
openpyxl.drawing.shapes, 153
233
openpyxl Documentation, Release 2.4.0
A add_chart() (openpyxl.chartsheet.chartsheet.Chartsheet
a (openpyxl.drawing.effect.AlphaReplaceEffect at- method), 116
tribute), 133 add_chart() (openpyxl.worksheet.worksheet.Worksheet
aboveAverage (openpyxl.formatting.rule.Rule attribute), method), 211
172 add_data_validation() (open-
absolute_coordinate() (in module openpyxl.utils), 185 pyxl.worksheet.worksheet.Worksheet method),
AbsoluteAnchor (class in open- 211
pyxl.drawing.spreadsheet_drawing), 158 add_filter_column() (open-
pyxl.worksheet.filters.AutoFilter
absoluteAnchor (openpyxl.drawing.spreadsheet_drawing.SpreadsheetDrawing method),
attribute), 160 196
AbstractCell (class in openpyxl.cell.interface), 78 add_image() (openpyxl.worksheet.worksheet.Worksheet
accent1 (openpyxl.drawing.colors.ColorMapping at- method), 211
tribute), 129 add_named_range() (open-
accent2 (openpyxl.drawing.colors.ColorMapping at- pyxl.workbook.workbook.Workbook method),
tribute), 129 192
accent3 (openpyxl.drawing.colors.ColorMapping at- add_print_title() (open-
tribute), 129 pyxl.worksheet.worksheet.Worksheet method),
accent4 (openpyxl.drawing.colors.ColorMapping at- 211
tribute), 129 add_sort_condition() (open-
accent5 (openpyxl.drawing.colors.ColorMapping at- pyxl.worksheet.filters.AutoFilter method),
tribute), 129 197
accent6 (openpyxl.drawing.colors.ColorMapping at- AdjPoint2D (class in openpyxl.drawing.shapes), 153
tribute), 129 AdjustHandleList (class in openpyxl.drawing.shapes),
action (openpyxl.drawing.text.Hyperlink attribute), 164 153
active (openpyxl.workbook.workbook.Workbook at- ahLst (openpyxl.drawing.shapes.CustomGeometry2D at-
tribute), 192 tribute), 154
active_cell (openpyxl.worksheet.worksheet.Worksheet at- algn (openpyxl.drawing.effect.OuterShadowEffect
tribute), 211 attribute), 136
activeCell (openpyxl.worksheet.views.Selection at- algn (openpyxl.drawing.effect.ReflectionEffect attribute),
tribute), 209 138
activeCellId (openpyxl.worksheet.views.Selection at- algn (openpyxl.drawing.fill.TileInfoProperties attribute),
tribute), 209 143
activePane (openpyxl.worksheet.views.Pane attribute), algn (openpyxl.drawing.line.LineProperties attribute),
209 151
add() (openpyxl.formatting.formatting.ConditionalFormattingalgn (openpyxl.drawing.text.ParagraphProperties at-
method), 170 tribute), 166
add() (openpyxl.utils.indexed_list.IndexedList method), algn (openpyxl.drawing.text.TabStop attribute), 169
186 algorithmName (openpyxl.chartsheet.protection.ChartsheetProtection
add() (openpyxl.worksheet.datavalidation.DataValidation attribute), 118
method), 193 algorithmName (openpyxl.worksheet.protection.SheetProtection
attribute), 207
235
openpyxl Documentation, Release 2.4.0
236 Index
openpyxl Documentation, Release 2.4.0
Index 237
openpyxl Documentation, Release 2.4.0
238 Index
openpyxl Documentation, Release 2.4.0
Index 239
openpyxl Documentation, Release 2.4.0
240 Index
openpyxl Documentation, Release 2.4.0
Index 241
openpyxl Documentation, Release 2.4.0
242 Index
openpyxl Documentation, Release 2.4.0
Index 243
openpyxl Documentation, Release 2.4.0
244 Index
openpyxl Documentation, Release 2.4.0
Index 245
openpyxl Documentation, Release 2.4.0
246 Index
openpyxl Documentation, Release 2.4.0
Index 247
openpyxl Documentation, Release 2.4.0
248 Index
openpyxl Documentation, Release 2.4.0
Index 249
openpyxl Documentation, Release 2.4.0
250 Index
openpyxl Documentation, Release 2.4.0
Index 251
openpyxl Documentation, Release 2.4.0
252 Index
openpyxl Documentation, Release 2.4.0
pyxl.worksheet.protection.SheetProtection K
attribute), 207 kern (openpyxl.drawing.text.CharacterProperties at-
insertRows (openpyxl.worksheet.protection.SheetProtection tribute), 162
attribute), 207 key (openpyxl.styles.hashable.HashableObject attribute),
InsufficientCoordinatesException, 186 182
Integer (class in openpyxl.descriptors.base), 124 key (openpyxl.styles.styleable.NumberFormatDescriptor
intercept (openpyxl.chart.trendline.Trendline attribute), attribute), 184
113 kumimoji (openpyxl.drawing.text.CharacterProperties at-
internal_value (openpyxl.cell.cell.Cell attribute), 78 tribute), 162
internal_value (openpyxl.cell.interface.AbstractCell at- kx (openpyxl.drawing.effect.OuterShadowEffect at-
tribute), 79 tribute), 136
internal_value (openpyxl.cell.read_only.ReadOnlyCell kx (openpyxl.drawing.effect.ReflectionEffect attribute),
attribute), 79 139
inv (openpyxl.drawing.colors.SystemColor attribute), 131 ky (openpyxl.drawing.effect.OuterShadowEffect at-
InvalidFileException, 186 tribute), 136
invalidUrl (openpyxl.drawing.text.Hyperlink attribute), ky (openpyxl.drawing.effect.ReflectionEffect attribute),
164 139
invertIfNegative (openpyxl.chart.marker.DataPoint
attribute), 102 L
invertIfNegative (openpyxl.chart.series.Series attribute), l (openpyxl.drawing.fill.RelativeRect attribute), 143
107 l (openpyxl.drawing.shapes.GeomRect attribute), 155
invertIfNegative (openpyxl.chart.series.XYSeries at- lang (openpyxl.chart.chartspace.ChartSpace attribute), 91
tribute), 108 lang (openpyxl.drawing.text.CharacterProperties at-
invGamma (openpyxl.drawing.colors.SystemColor tribute), 162
attribute), 131 lastClr (openpyxl.drawing.colors.SystemColor attribute),
is_builtin() (in module openpyxl.styles.numbers), 184 131
is_date (openpyxl.cell.cell.Cell attribute), 78 lastEdited (openpyxl.workbook.properties.FileVersion at-
is_date (openpyxl.cell.interface.AbstractCell attribute), tribute), 190
79 lat (openpyxl.drawing.shapes.SphereCoords attribute),
is_date (openpyxl.cell.read_only.ReadOnlyCell at- 158
tribute), 79 latin (openpyxl.drawing.text.CharacterProperties at-
is_date_format() (in module openpyxl.styles.numbers), tribute), 162
184 latinLnBrk (openpyxl.drawing.text.ParagraphProperties
isgenerator() (in module openpyxl.worksheet), 193 attribute), 167
isgenerator() (in module openpyxl.worksheet.worksheet), Layout (class in openpyxl.chart.layout), 99
213 layout (openpyxl.chart.axis.DisplayUnitsLabel attribute),
isgenerator() (in module openpyxl.writer.write_only), 216 84
iter_rows() (openpyxl.worksheet.worksheet.Worksheet layout (openpyxl.chart.chartspace.PlotArea attribute), 93
method), 213 layout (openpyxl.chart.legend.Legend attribute), 100
iterate (openpyxl.workbook.properties.CalcProperties at- layout (openpyxl.chart.title.Title attribute), 112
tribute), 190 layout (openpyxl.chart.trendline.TrendlineLabel at-
iterateCount (openpyxl.workbook.properties.CalcProperties tribute), 113
attribute), 190 layoutTarget (openpyxl.chart.layout.ManualLayout at-
iterateDelta (openpyxl.workbook.properties.CalcProperties tribute), 99
attribute), 190 lblAlgn (openpyxl.chart.axis.TextAxis attribute), 87
iterparse() (in module openpyxl.xml.functions), 216 lblOffset (openpyxl.chart.axis.DateAxis attribute), 83
lblOffset (openpyxl.chart.axis.TextAxis attribute), 87
J left (openpyxl.styles.borders.Border attribute), 178
justifyLastLine (openpyxl.styles.alignment.Alignment at- left (openpyxl.styles.fills.GradientFill attribute), 180
tribute), 177 LEFT (openpyxl.worksheet.header_footer.HeaderFooterItem
justLastX (openpyxl.comments.properties.Properties at- attribute), 202
tribute), 122 left (openpyxl.worksheet.page.PageMargins attribute),
203
Index 253
openpyxl Documentation, Release 2.4.0
254 Index
openpyxl Documentation, Release 2.4.0
Index 255
openpyxl Documentation, Release 2.4.0
256 Index
openpyxl Documentation, Release 2.4.0
Index 257
openpyxl Documentation, Release 2.4.0
258 Index
openpyxl Documentation, Release 2.4.0
Index 259
openpyxl Documentation, Release 2.4.0
260 Index
openpyxl Documentation, Release 2.4.0
Index 261
openpyxl Documentation, Release 2.4.0
262 Index
openpyxl Documentation, Release 2.4.0
Index 263
openpyxl Documentation, Release 2.4.0
264 Index
openpyxl Documentation, Release 2.4.0
Index 265
openpyxl Documentation, Release 2.4.0
266 Index
openpyxl Documentation, Release 2.4.0
Index 267
openpyxl Documentation, Release 2.4.0
268 Index
openpyxl Documentation, Release 2.4.0
Index 269
openpyxl Documentation, Release 2.4.0
270 Index
openpyxl Documentation, Release 2.4.0
Index 271
openpyxl Documentation, Release 2.4.0
272 Index
openpyxl Documentation, Release 2.4.0
Index 273
openpyxl Documentation, Release 2.4.0
274 Index
openpyxl Documentation, Release 2.4.0
Index 275
openpyxl Documentation, Release 2.4.0
276 Index
openpyxl Documentation, Release 2.4.0
Index 277
openpyxl Documentation, Release 2.4.0
278 Index
openpyxl Documentation, Release 2.4.0
Z
z (openpyxl.drawing.shapes.Point3D attribute), 156
z (openpyxl.drawing.shapes.Shape3D attribute), 157
Index 279