File: worksheet_properties.rst

package info (click to toggle)
openpyxl 2.4.9-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 6,768 kB
  • sloc: python: 34,453; xml: 12,359; makefile: 124
file content (57 lines) | stat: -rw-r--r-- 1,792 bytes parent folder | download | duplicates (3)
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
Additional Worksheet Properties
===============================

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

Available properties for worksheets
-----------------------------------

* "enableFormatConditionsCalculation"
* "filterMode"
* "published"
* "syncHorizontal"
* "syncRef"
* "syncVertical"
* "transitionEvaluation"
* "transitionEntry"
* "tabColor"

Available fields for page setup properties
------------------------------------------

"autoPageBreaks"
"fitToPage"

Available fields for outlines
-----------------------------

* "applyStyles"
* "summaryBelow"
* "summaryRight"
* "showOutlineSymbols"

see http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.sheetproperties%28v=office.14%29.aspx_ for details.

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


.. :: doctest

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