Source code

Download source archive ↓

src/openpyxl/workbook/properties.py

1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5    String,
6    Float,
7    Integer,
8    Bool,
9    NoneSet,
10    Set,
11)
12
13from openpyxl.descriptors.excel import Guid
14
15
16class WorkbookProperties(Serialisable):
17
18    tagname = "workbookPr"
19
20    date1904 = Bool(allow_none=True)
21    dateCompatibility = Bool(allow_none=True)
22    showObjects = NoneSet(values=(['all', 'placeholders']))
23    showBorderUnselectedTables = Bool(allow_none=True)
24    filterPrivacy = Bool(allow_none=True)
25    promptedSolutions = Bool(allow_none=True)
26    showInkAnnotation = Bool(allow_none=True)
27    backupFile = Bool(allow_none=True)
28    saveExternalLinkValues = Bool(allow_none=True)
29    updateLinks = NoneSet(values=(['userSet', 'never', 'always']))
30    codeName = String(allow_none=True)
31    hidePivotFieldList = Bool(allow_none=True)
32    showPivotChartFilter = Bool(allow_none=True)
33    allowRefreshQuery = Bool(allow_none=True)
34    publishItems = Bool(allow_none=True)
35    checkCompatibility = Bool(allow_none=True)
36    autoCompressPictures = Bool(allow_none=True)
37    refreshAllConnections = Bool(allow_none=True)
38    defaultThemeVersion = Integer(allow_none=True)
39
40    def __init__(self,
41                 date1904=None,
42                 dateCompatibility=None,
43                 showObjects=None,
44                 showBorderUnselectedTables=None,
45                 filterPrivacy=None,
46                 promptedSolutions=None,
47                 showInkAnnotation=None,
48                 backupFile=None,
49                 saveExternalLinkValues=None,
50                 updateLinks=None,
51                 codeName=None,
52                 hidePivotFieldList=None,
53                 showPivotChartFilter=None,
54                 allowRefreshQuery=None,
55                 publishItems=None,
56                 checkCompatibility=None,
57                 autoCompressPictures=None,
58                 refreshAllConnections=None,
59                 defaultThemeVersion=None,
60                ):
61        self.date1904 = date1904
62        self.dateCompatibility = dateCompatibility
63        self.showObjects = showObjects
64        self.showBorderUnselectedTables = showBorderUnselectedTables
65        self.filterPrivacy = filterPrivacy
66        self.promptedSolutions = promptedSolutions
67        self.showInkAnnotation = showInkAnnotation
68        self.backupFile = backupFile
69        self.saveExternalLinkValues = saveExternalLinkValues
70        self.updateLinks = updateLinks
71        self.codeName = codeName
72        self.hidePivotFieldList = hidePivotFieldList
73        self.showPivotChartFilter = showPivotChartFilter
74        self.allowRefreshQuery = allowRefreshQuery
75        self.publishItems = publishItems
76        self.checkCompatibility = checkCompatibility
77        self.autoCompressPictures = autoCompressPictures
78        self.refreshAllConnections = refreshAllConnections
79        self.defaultThemeVersion = defaultThemeVersion
80
81
82class CalcProperties(Serialisable):
83
84    tagname = "calcPr"
85
86    calcId = Integer()
87    calcMode = NoneSet(values=(['manual', 'auto', 'autoNoTable']))
88    fullCalcOnLoad = Bool(allow_none=True)
89    refMode = NoneSet(values=(['A1', 'R1C1']))
90    iterate = Bool(allow_none=True)
91    iterateCount = Integer(allow_none=True)
92    iterateDelta = Float(allow_none=True)
93    fullPrecision = Bool(allow_none=True)
94    calcCompleted = Bool(allow_none=True)
95    calcOnSave = Bool(allow_none=True)
96    concurrentCalc = Bool(allow_none=True)
97    concurrentManualCount = Integer(allow_none=True)
98    forceFullCalc = Bool(allow_none=True)
99
100    def __init__(self,
101                 calcId=124519,
102                 calcMode=None,
103                 fullCalcOnLoad=True,
104                 refMode=None,
105                 iterate=None,
106                 iterateCount=None,
107                 iterateDelta=None,
108                 fullPrecision=None,
109                 calcCompleted=None,
110                 calcOnSave=None,
111                 concurrentCalc=None,
112                 concurrentManualCount=None,
113                 forceFullCalc=None,
114                ):
115        self.calcId = calcId
116        self.calcMode = calcMode
117        self.fullCalcOnLoad = fullCalcOnLoad
118        self.refMode = refMode
119        self.iterate = iterate
120        self.iterateCount = iterateCount
121        self.iterateDelta = iterateDelta
122        self.fullPrecision = fullPrecision
123        self.calcCompleted = calcCompleted
124        self.calcOnSave = calcOnSave
125        self.concurrentCalc = concurrentCalc
126        self.concurrentManualCount = concurrentManualCount
127        self.forceFullCalc = forceFullCalc
128
129
130class FileVersion(Serialisable):
131
132    tagname = "fileVersion"
133
134    appName = String(allow_none=True)
135    lastEdited = String(allow_none=True)
136    lowestEdited = String(allow_none=True)
137    rupBuild = String(allow_none=True)
138    codeName = Guid(allow_none=True)
139
140    def __init__(self,
141                 appName=None,
142                 lastEdited=None,
143                 lowestEdited=None,
144                 rupBuild=None,
145                 codeName=None,
146                ):
147        self.appName = appName
148        self.lastEdited = lastEdited
149        self.lowestEdited = lowestEdited
150        self.rupBuild = rupBuild
151        self.codeName = codeName