Source code

Download source archive ↓

src/openpyxl/workbook/views.py

1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5    Typed,
6    Sequence,
7    String,
8    Float,
9    Integer,
10    Bool,
11    NoneSet,
12    Set,
13)
14from openpyxl.descriptors.excel import (
15    ExtensionList,
16    Guid,
17)
18
19
20class BookView(Serialisable):
21
22    tagname = "workbookView"
23
24    visibility = NoneSet(values=(['visible', 'hidden', 'veryHidden']))
25    minimized = Bool(allow_none=True)
26    showHorizontalScroll = Bool(allow_none=True)
27    showVerticalScroll = Bool(allow_none=True)
28    showSheetTabs = Bool(allow_none=True)
29    xWindow = Integer(allow_none=True)
30    yWindow = Integer(allow_none=True)
31    windowWidth = Integer(allow_none=True)
32    windowHeight = Integer(allow_none=True)
33    tabRatio = Integer(allow_none=True)
34    firstSheet = Integer(allow_none=True)
35    activeTab = Integer(allow_none=True)
36    autoFilterDateGrouping = Bool(allow_none=True)
37    extLst = Typed(expected_type=ExtensionList, allow_none=True)
38
39    __elements__ = ()
40
41    def __init__(self,
42                 visibility="visible",
43                 minimized=False,
44                 showHorizontalScroll=True,
45                 showVerticalScroll=True,
46                 showSheetTabs=True,
47                 xWindow=None,
48                 yWindow=None,
49                 windowWidth=None,
50                 windowHeight=None,
51                 tabRatio=600,
52                 firstSheet=0,
53                 activeTab=0,
54                 autoFilterDateGrouping=True,
55                 extLst=None,
56                ):
57        self.visibility = visibility
58        self.minimized = minimized
59        self.showHorizontalScroll = showHorizontalScroll
60        self.showVerticalScroll = showVerticalScroll
61        self.showSheetTabs = showSheetTabs
62        self.xWindow = xWindow
63        self.yWindow = yWindow
64        self.windowWidth = windowWidth
65        self.windowHeight = windowHeight
66        self.tabRatio = tabRatio
67        self.firstSheet = firstSheet
68        self.activeTab = activeTab
69        self.autoFilterDateGrouping = autoFilterDateGrouping
70
71
72class CustomWorkbookView(Serialisable):
73
74    tagname = "customWorkbookView"
75
76    name = String()
77    guid = Guid()
78    autoUpdate = Bool(allow_none=True)
79    mergeInterval = Integer(allow_none=True)
80    changesSavedWin = Bool(allow_none=True)
81    onlySync = Bool(allow_none=True)
82    personalView = Bool(allow_none=True)
83    includePrintSettings = Bool(allow_none=True)
84    includeHiddenRowCol = Bool(allow_none=True)
85    maximized = Bool(allow_none=True)
86    minimized = Bool(allow_none=True)
87    showHorizontalScroll = Bool(allow_none=True)
88    showVerticalScroll = Bool(allow_none=True)
89    showSheetTabs = Bool(allow_none=True)
90    xWindow = Integer(allow_none=True)
91    yWindow = Integer(allow_none=True)
92    windowWidth = Integer()
93    windowHeight = Integer()
94    tabRatio = Integer(allow_none=True)
95    activeSheetId = Integer()
96    showFormulaBar = Bool(allow_none=True)
97    showStatusbar = Bool(allow_none=True)
98    showComments = NoneSet(values=(['commNone', 'commIndicator',
99                                'commIndAndComment']))
100    showObjects = NoneSet(values=(['all', 'placeholders']))
101    extLst = Typed(expected_type=ExtensionList, allow_none=True)
102
103    __elements__ = ()
104
105    def __init__(self,
106                 name=None,
107                 guid=None,
108                 autoUpdate=None,
109                 mergeInterval=None,
110                 changesSavedWin=None,
111                 onlySync=None,
112                 personalView=None,
113                 includePrintSettings=None,
114                 includeHiddenRowCol=None,
115                 maximized=None,
116                 minimized=None,
117                 showHorizontalScroll=None,
118                 showVerticalScroll=None,
119                 showSheetTabs=None,
120                 xWindow=None,
121                 yWindow=None,
122                 windowWidth=None,
123                 windowHeight=None,
124                 tabRatio=None,
125                 activeSheetId=None,
126                 showFormulaBar=None,
127                 showStatusbar=None,
128                 showComments="commIndicator",
129                 showObjects="all",
130                 extLst=None,
131                ):
132        self.name = name
133        self.guid = guid
134        self.autoUpdate = autoUpdate
135        self.mergeInterval = mergeInterval
136        self.changesSavedWin = changesSavedWin
137        self.onlySync = onlySync
138        self.personalView = personalView
139        self.includePrintSettings = includePrintSettings
140        self.includeHiddenRowCol = includeHiddenRowCol
141        self.maximized = maximized
142        self.minimized = minimized
143        self.showHorizontalScroll = showHorizontalScroll
144        self.showVerticalScroll = showVerticalScroll
145        self.showSheetTabs = showSheetTabs
146        self.xWindow = xWindow
147        self.yWindow = yWindow
148        self.windowWidth = windowWidth
149        self.windowHeight = windowHeight
150        self.tabRatio = tabRatio
151        self.activeSheetId = activeSheetId
152        self.showFormulaBar = showFormulaBar
153        self.showStatusbar = showStatusbar
154        self.showComments = showComments
155        self.showObjects = showObjects