1# Copyright (c) 2010-2024 openpyxl
2
3from openpyxl.descriptors.serialisable import Serialisable
4from openpyxl.descriptors import (
5 Typed,
6 Bool,
7 Float,
8 Set,
9 NoneSet,
10 String,
11 Integer,
12 DateTime,
13 Sequence,
14)
15
16from openpyxl.descriptors.excel import (
17 HexBinary,
18 ExtensionList,
19 Relation,
20)
21from openpyxl.descriptors.nested import NestedInteger
22from openpyxl.descriptors.sequence import (
23 NestedSequence,
24 MultiSequence,
25 MultiSequencePart,
26)
27from openpyxl.xml.constants import SHEET_MAIN_NS
28from openpyxl.xml.functions import tostring
29from openpyxl.packaging.relationship import (
30 RelationshipList,
31 Relationship,
32 get_rels_path
33)
34
35from .table import (
36 PivotArea,
37 Reference,
38)
39from .fields import (
40 Boolean,
41 Error,
42 Missing,
43 Number,
44 Text,
45 TupleList,
46 DateTimeField,
47)
48
49class MeasureDimensionMap(Serialisable):
50
51 tagname = "map"
52
53 measureGroup = Integer(allow_none=True)
54 dimension = Integer(allow_none=True)
55
56 def __init__(self,
57 measureGroup=None,
58 dimension=None,
59 ):
60 self.measureGroup = measureGroup
61 self.dimension = dimension
62
63
64class MeasureGroup(Serialisable):
65
66 tagname = "measureGroup"
67
68 name = String()
69 caption = String()
70
71 def __init__(self,
72 name=None,
73 caption=None,
74 ):
75 self.name = name
76 self.caption = caption
77
78
79class PivotDimension(Serialisable):
80
81 tagname = "dimension"
82
83 measure = Bool()
84 name = String()
85 uniqueName = String()
86 caption = String()
87
88 def __init__(self,
89 measure=None,
90 name=None,
91 uniqueName=None,
92 caption=None,
93 ):
94 self.measure = measure
95 self.name = name
96 self.uniqueName = uniqueName
97 self.caption = caption
98
99
100class CalculatedMember(Serialisable):
101
102 tagname = "calculatedMember"
103
104 name = String()
105 mdx = String()
106 memberName = String(allow_none=True)
107 hierarchy = String(allow_none=True)
108 parent = String(allow_none=True)
109 solveOrder = Integer(allow_none=True)
110 set = Bool()
111 extLst = Typed(expected_type=ExtensionList, allow_none=True)
112
113 __elements__ = ()
114
115 def __init__(self,
116 name=None,
117 mdx=None,
118 memberName=None,
119 hierarchy=None,
120 parent=None,
121 solveOrder=None,
122 set=None,
123 extLst=None,
124 ):
125 self.name = name
126 self.mdx = mdx
127 self.memberName = memberName
128 self.hierarchy = hierarchy
129 self.parent = parent
130 self.solveOrder = solveOrder
131 self.set = set
132 #self.extLst = extLst
133
134
135class CalculatedItem(Serialisable):
136
137 tagname = "calculatedItem"
138
139 field = Integer(allow_none=True)
140 formula = String()
141 pivotArea = Typed(expected_type=PivotArea, )
142 extLst = Typed(expected_type=ExtensionList, allow_none=True)
143
144 __elements__ = ('pivotArea', 'extLst')
145
146 def __init__(self,
147 field=None,
148 formula=None,
149 pivotArea=None,
150 extLst=None,
151 ):
152 self.field = field
153 self.formula = formula
154 self.pivotArea = pivotArea
155 self.extLst = extLst
156
157
158class ServerFormat(Serialisable):
159
160 tagname = "serverFormat"
161
162 culture = String(allow_none=True)
163 format = String(allow_none=True)
164
165 def __init__(self,
166 culture=None,
167 format=None,
168 ):
169 self.culture = culture
170 self.format = format
171
172
173class Query(Serialisable):
174
175 tagname = "query"
176
177 mdx = String()
178 tpls = Typed(expected_type=TupleList, allow_none=True)
179
180 __elements__ = ('tpls',)
181
182 def __init__(self,
183 mdx=None,
184 tpls=None,
185 ):
186 self.mdx = mdx
187 self.tpls = tpls
188
189
190class OLAPSet(Serialisable):
191
192 tagname = "set"
193
194 count = Integer()
195 maxRank = Integer()
196 setDefinition = String()
197 sortType = NoneSet(values=(['ascending', 'descending', 'ascendingAlpha',
198 'descendingAlpha', 'ascendingNatural', 'descendingNatural']))
199 queryFailed = Bool()
200 tpls = Typed(expected_type=TupleList, allow_none=True)
201 sortByTuple = Typed(expected_type=TupleList, allow_none=True)
202
203 __elements__ = ('tpls', 'sortByTuple')
204
205 def __init__(self,
206 count=None,
207 maxRank=None,
208 setDefinition=None,
209 sortType=None,
210 queryFailed=None,
211 tpls=None,
212 sortByTuple=None,
213 ):
214 self.count = count
215 self.maxRank = maxRank
216 self.setDefinition = setDefinition
217 self.sortType = sortType
218 self.queryFailed = queryFailed
219 self.tpls = tpls
220 self.sortByTuple = sortByTuple
221
222
223class PCDSDTCEntries(Serialisable):
224 # Implements CT_PCDSDTCEntries
225
226 tagname = "entries"
227
228 count = Integer(allow_none=True)
229 # elements are choice
230 m = Typed(expected_type=Missing, allow_none=True)
231 n = Typed(expected_type=Number, allow_none=True)
232 e = Typed(expected_type=Error, allow_none=True)
233 s = Typed(expected_type=Text, allow_none=True)
234
235 __elements__ = ('m', 'n', 'e', 's')
236
237 def __init__(self,
238 count=None,
239 m=None,
240 n=None,
241 e=None,
242 s=None,
243 ):
244 self.count = count
245 self.m = m
246 self.n = n
247 self.e = e
248 self.s = s
249
250
251class TupleCache(Serialisable):
252
253 tagname = "tupleCache"
254
255 entries = Typed(expected_type=PCDSDTCEntries, allow_none=True)
256 sets = NestedSequence(expected_type=OLAPSet, count=True)
257 queryCache = NestedSequence(expected_type=Query, count=True)
258 serverFormats = NestedSequence(expected_type=ServerFormat, count=True)
259 extLst = Typed(expected_type=ExtensionList, allow_none=True)
260
261 __elements__ = ('entries', 'sets', 'queryCache', 'serverFormats', 'extLst')
262
263 def __init__(self,
264 entries=None,
265 sets=(),
266 queryCache=(),
267 serverFormats=(),
268 extLst=None,
269 ):
270 self.entries = entries
271 self.sets = sets
272 self.queryCache = queryCache
273 self.serverFormats = serverFormats
274 self.extLst = extLst
275
276
277class OLAPKPI(Serialisable):
278
279 tagname = "kpi"
280
281 uniqueName = String()
282 caption = String(allow_none=True)
283 displayFolder = String(allow_none=True)
284 measureGroup = String(allow_none=True)
285 parent = String(allow_none=True)
286 value = String()
287 goal = String(allow_none=True)
288 status = String(allow_none=True)
289 trend = String(allow_none=True)
290 weight = String(allow_none=True)
291 time = String(allow_none=True)
292
293 def __init__(self,
294 uniqueName=None,
295 caption=None,
296 displayFolder=None,
297 measureGroup=None,
298 parent=None,
299 value=None,
300 goal=None,
301 status=None,
302 trend=None,
303 weight=None,
304 time=None,
305 ):
306 self.uniqueName = uniqueName
307 self.caption = caption
308 self.displayFolder = displayFolder
309 self.measureGroup = measureGroup
310 self.parent = parent
311 self.value = value
312 self.goal = goal
313 self.status = status
314 self.trend = trend
315 self.weight = weight
316 self.time = time
317
318
319class GroupMember(Serialisable):
320
321 tagname = "groupMember"
322
323 uniqueName = String()
324 group = Bool()
325
326 def __init__(self,
327 uniqueName=None,
328 group=None,
329 ):
330 self.uniqueName = uniqueName
331 self.group = group
332
333
334class LevelGroup(Serialisable):
335
336 tagname = "group"
337
338 name = String()
339 uniqueName = String()
340 caption = String()
341 uniqueParent = String()
342 id = Integer()
343 groupMembers = NestedSequence(expected_type=GroupMember, count=True)
344
345 __elements__ = ('groupMembers',)
346
347 def __init__(self,
348 name=None,
349 uniqueName=None,
350 caption=None,
351 uniqueParent=None,
352 id=None,
353 groupMembers=(),
354 ):
355 self.name = name
356 self.uniqueName = uniqueName
357 self.caption = caption
358 self.uniqueParent = uniqueParent
359 self.id = id
360 self.groupMembers = groupMembers
361
362
363class GroupLevel(Serialisable):
364
365 tagname = "groupLevel"
366
367 uniqueName = String()
368 caption = String()
369 user = Bool()
370 customRollUp = Bool()
371 groups = NestedSequence(expected_type=LevelGroup, count=True)
372 extLst = Typed(expected_type=ExtensionList, allow_none=True)
373
374 __elements__ = ('groups', 'extLst')
375
376 def __init__(self,
377 uniqueName=None,
378 caption=None,
379 user=None,
380 customRollUp=None,
381 groups=(),
382 extLst=None,
383 ):
384 self.uniqueName = uniqueName
385 self.caption = caption
386 self.user = user
387 self.customRollUp = customRollUp
388 self.groups = groups
389 self.extLst = extLst
390
391
392class FieldUsage(Serialisable):
393
394 tagname = "fieldUsage"
395
396 x = Integer()
397
398 def __init__(self,
399 x=None,
400 ):
401 self.x = x
402
403
404class CacheHierarchy(Serialisable):
405
406 tagname = "cacheHierarchy"
407
408 uniqueName = String()
409 caption = String(allow_none=True)
410 measure = Bool()
411 set = Bool()
412 parentSet = Integer(allow_none=True)
413 iconSet = Integer()
414 attribute = Bool()
415 time = Bool()
416 keyAttribute = Bool()
417 defaultMemberUniqueName = String(allow_none=True)
418 allUniqueName = String(allow_none=True)
419 allCaption = String(allow_none=True)
420 dimensionUniqueName = String(allow_none=True)
421 displayFolder = String(allow_none=True)
422 measureGroup = String(allow_none=True)
423 measures = Bool()
424 count = Integer()
425 oneField = Bool()
426 memberValueDatatype = Integer(allow_none=True)
427 unbalanced = Bool(allow_none=True)
428 unbalancedGroup = Bool(allow_none=True)
429 hidden = Bool()
430 fieldsUsage = NestedSequence(expected_type=FieldUsage, count=True)
431 groupLevels = NestedSequence(expected_type=GroupLevel, count=True)
432 extLst = Typed(expected_type=ExtensionList, allow_none=True)
433
434 __elements__ = ('fieldsUsage', 'groupLevels')
435
436 def __init__(self,
437 uniqueName="",
438 caption=None,
439 measure=None,
440 set=None,
441 parentSet=None,
442 iconSet=0,
443 attribute=None,
444 time=None,
445 keyAttribute=None,
446 defaultMemberUniqueName=None,
447 allUniqueName=None,
448 allCaption=None,
449 dimensionUniqueName=None,
450 displayFolder=None,
451 measureGroup=None,
452 measures=None,
453 count=None,
454 oneField=None,
455 memberValueDatatype=None,
456 unbalanced=None,
457 unbalancedGroup=None,
458 hidden=None,
459 fieldsUsage=(),
460 groupLevels=(),
461 extLst=None,
462 ):
463 self.uniqueName = uniqueName
464 self.caption = caption
465 self.measure = measure
466 self.set = set
467 self.parentSet = parentSet
468 self.iconSet = iconSet
469 self.attribute = attribute
470 self.time = time
471 self.keyAttribute = keyAttribute
472 self.defaultMemberUniqueName = defaultMemberUniqueName
473 self.allUniqueName = allUniqueName
474 self.allCaption = allCaption
475 self.dimensionUniqueName = dimensionUniqueName
476 self.displayFolder = displayFolder
477 self.measureGroup = measureGroup
478 self.measures = measures
479 self.count = count
480 self.oneField = oneField
481 self.memberValueDatatype = memberValueDatatype
482 self.unbalanced = unbalanced
483 self.unbalancedGroup = unbalancedGroup
484 self.hidden = hidden
485 self.fieldsUsage = fieldsUsage
486 self.groupLevels = groupLevels
487 self.extLst = extLst
488
489
490class GroupItems(Serialisable):
491
492 tagname = "groupItems"
493
494 m = Sequence(expected_type=Missing)
495 n = Sequence(expected_type=Number)
496 b = Sequence(expected_type=Boolean)
497 e = Sequence(expected_type=Error)
498 s = Sequence(expected_type=Text)
499 d = Sequence(expected_type=DateTimeField,)
500
501 __elements__ = ('m', 'n', 'b', 'e', 's', 'd')
502 __attrs__ = ("count", )
503
504 def __init__(self,
505 count=None,
506 m=(),
507 n=(),
508 b=(),
509 e=(),
510 s=(),
511 d=(),
512 ):
513 self.m = m
514 self.n = n
515 self.b = b
516 self.e = e
517 self.s = s
518 self.d = d
519
520
521 @property
522 def count(self):
523 return len(self.m + self.n + self.b + self.e + self.s + self.d)
524
525
526class RangePr(Serialisable):
527
528 tagname = "rangePr"
529
530 autoStart = Bool(allow_none=True)
531 autoEnd = Bool(allow_none=True)
532 groupBy = NoneSet(values=(['range', 'seconds', 'minutes', 'hours', 'days',
533 'months', 'quarters', 'years']))
534 startNum = Float(allow_none=True)
535 endNum = Float(allow_none=True)
536 startDate = DateTime(allow_none=True)
537 endDate = DateTime(allow_none=True)
538 groupInterval = Float(allow_none=True)
539
540 def __init__(self,
541 autoStart=True,
542 autoEnd=True,
543 groupBy="range",
544 startNum=None,
545 endNum=None,
546 startDate=None,
547 endDate=None,
548 groupInterval=1,
549 ):
550 self.autoStart = autoStart
551 self.autoEnd = autoEnd
552 self.groupBy = groupBy
553 self.startNum = startNum
554 self.endNum = endNum
555 self.startDate = startDate
556 self.endDate = endDate
557 self.groupInterval = groupInterval
558
559
560class FieldGroup(Serialisable):
561
562 tagname = "fieldGroup"
563
564 par = Integer(allow_none=True)
565 base = Integer(allow_none=True)
566 rangePr = Typed(expected_type=RangePr, allow_none=True)
567 discretePr = NestedSequence(expected_type=NestedInteger, count=True)
568 groupItems = Typed(expected_type=GroupItems, allow_none=True)
569
570 __elements__ = ('rangePr', 'discretePr', 'groupItems')
571
572 def __init__(self,
573 par=None,
574 base=None,
575 rangePr=None,
576 discretePr=(),
577 groupItems=None,
578 ):
579 self.par = par
580 self.base = base
581 self.rangePr = rangePr
582 self.discretePr = discretePr
583 self.groupItems = groupItems
584
585
586class SharedItems(Serialisable):
587
588 tagname = "sharedItems"
589
590 _fields = MultiSequence()
591 m = MultiSequencePart(expected_type=Missing, store="_fields")
592 n = MultiSequencePart(expected_type=Number, store="_fields")
593 b = MultiSequencePart(expected_type=Boolean, store="_fields")
594 e = MultiSequencePart(expected_type=Error, store="_fields")
595 s = MultiSequencePart(expected_type=Text, store="_fields")
596 d = MultiSequencePart(expected_type=DateTimeField, store="_fields")
597 # attributes are optional and must be derived from associated cache records
598 containsSemiMixedTypes = Bool(allow_none=True)
599 containsNonDate = Bool(allow_none=True)
600 containsDate = Bool(allow_none=True)
601 containsString = Bool(allow_none=True)
602 containsBlank = Bool(allow_none=True)
603 containsMixedTypes = Bool(allow_none=True)
604 containsNumber = Bool(allow_none=True)
605 containsInteger = Bool(allow_none=True)
606 minValue = Float(allow_none=True)
607 maxValue = Float(allow_none=True)
608 minDate = DateTime(allow_none=True)
609 maxDate = DateTime(allow_none=True)
610 longText = Bool(allow_none=True)
611
612 __attrs__ = ('count', 'containsBlank', 'containsDate', 'containsInteger',
613 'containsMixedTypes', 'containsNonDate', 'containsNumber',
614 'containsSemiMixedTypes', 'containsString', 'minValue', 'maxValue',
615 'minDate', 'maxDate', 'longText')
616
617 def __init__(self,
618 _fields=(),
619 containsSemiMixedTypes=None,
620 containsNonDate=None,
621 containsDate=None,
622 containsString=None,
623 containsBlank=None,
624 containsMixedTypes=None,
625 containsNumber=None,
626 containsInteger=None,
627 minValue=None,
628 maxValue=None,
629 minDate=None,
630 maxDate=None,
631 count=None,
632 longText=None,
633 ):
634 self._fields = _fields
635 self.containsBlank = containsBlank
636 self.containsDate = containsDate
637 self.containsNonDate = containsNonDate
638 self.containsString = containsString
639 self.containsMixedTypes = containsMixedTypes
640 self.containsSemiMixedTypes = containsSemiMixedTypes
641 self.containsNumber = containsNumber
642 self.containsInteger = containsInteger
643 self.minValue = minValue
644 self.maxValue = maxValue
645 self.minDate = minDate
646 self.maxDate = maxDate
647 self.longText = longText
648
649
650 @property
651 def count(self):
652 return len(self._fields)
653
654
655class CacheField(Serialisable):
656
657 tagname = "cacheField"
658
659 sharedItems = Typed(expected_type=SharedItems, allow_none=True)
660 fieldGroup = Typed(expected_type=FieldGroup, allow_none=True)
661 mpMap = NestedInteger(allow_none=True, attribute="v")
662 extLst = Typed(expected_type=ExtensionList, allow_none=True)
663 name = String()
664 caption = String(allow_none=True)
665 propertyName = String(allow_none=True)
666 serverField = Bool(allow_none=True)
667 uniqueList = Bool(allow_none=True)
668 numFmtId = Integer(allow_none=True)
669 formula = String(allow_none=True)
670 sqlType = Integer(allow_none=True)
671 hierarchy = Integer(allow_none=True)
672 level = Integer(allow_none=True)
673 databaseField = Bool(allow_none=True)
674 mappingCount = Integer(allow_none=True)
675 memberPropertyField = Bool(allow_none=True)
676
677 __elements__ = ('sharedItems', 'fieldGroup', 'mpMap')
678
679 def __init__(self,
680 sharedItems=None,
681 fieldGroup=None,
682 mpMap=None,
683 extLst=None,
684 name=None,
685 caption=None,
686 propertyName=None,
687 serverField=None,
688 uniqueList=True,
689 numFmtId=None,
690 formula=None,
691 sqlType=0,
692 hierarchy=0,
693 level=0,
694 databaseField=True,
695 mappingCount=None,
696 memberPropertyField=None,
697 ):
698 self.sharedItems = sharedItems
699 self.fieldGroup = fieldGroup
700 self.mpMap = mpMap
701 self.extLst = extLst
702 self.name = name
703 self.caption = caption
704 self.propertyName = propertyName
705 self.serverField = serverField
706 self.uniqueList = uniqueList
707 self.numFmtId = numFmtId
708 self.formula = formula
709 self.sqlType = sqlType
710 self.hierarchy = hierarchy
711 self.level = level
712 self.databaseField = databaseField
713 self.mappingCount = mappingCount
714 self.memberPropertyField = memberPropertyField
715
716
717class RangeSet(Serialisable):
718
719 tagname = "rangeSet"
720
721 i1 = Integer(allow_none=True)
722 i2 = Integer(allow_none=True)
723 i3 = Integer(allow_none=True)
724 i4 = Integer(allow_none=True)
725 ref = String()
726 name = String(allow_none=True)
727 sheet = String(allow_none=True)
728
729 def __init__(self,
730 i1=None,
731 i2=None,
732 i3=None,
733 i4=None,
734 ref=None,
735 name=None,
736 sheet=None,
737 ):
738 self.i1 = i1
739 self.i2 = i2
740 self.i3 = i3
741 self.i4 = i4
742 self.ref = ref
743 self.name = name
744 self.sheet = sheet
745
746
747class PageItem(Serialisable):
748
749 tagname = "pageItem"
750
751 name = String()
752
753 def __init__(self,
754 name=None,
755 ):
756 self.name = name
757
758
759class Consolidation(Serialisable):
760
761 tagname = "consolidation"
762
763 autoPage = Bool(allow_none=True)
764 pages = NestedSequence(expected_type=PageItem, count=True)
765 rangeSets = NestedSequence(expected_type=RangeSet, count=True)
766
767 __elements__ = ('pages', 'rangeSets')
768
769 def __init__(self,
770 autoPage=None,
771 pages=(),
772 rangeSets=(),
773 ):
774 self.autoPage = autoPage
775 self.pages = pages
776 self.rangeSets = rangeSets
777
778
779class WorksheetSource(Serialisable):
780
781 tagname = "worksheetSource"
782
783 ref = String(allow_none=True)
784 name = String(allow_none=True)
785 sheet = String(allow_none=True)
786
787 def __init__(self,
788 ref=None,
789 name=None,
790 sheet=None,
791 ):
792 self.ref = ref
793 self.name = name
794 self.sheet = sheet
795
796
797class CacheSource(Serialisable):
798
799 tagname = "cacheSource"
800
801 type = Set(values=(['worksheet', 'external', 'consolidation', 'scenario']))
802 connectionId = Integer(allow_none=True)
803 # some elements are choice
804 worksheetSource = Typed(expected_type=WorksheetSource, allow_none=True)
805 consolidation = Typed(expected_type=Consolidation, allow_none=True)
806 extLst = Typed(expected_type=ExtensionList, allow_none=True)
807
808 __elements__ = ('worksheetSource', 'consolidation',)
809
810 def __init__(self,
811 type=None,
812 connectionId=None,
813 worksheetSource=None,
814 consolidation=None,
815 extLst=None,
816 ):
817 self.type = type
818 self.connectionId = connectionId
819 self.worksheetSource = worksheetSource
820 self.consolidation = consolidation
821
822
823class CacheDefinition(Serialisable):
824
825 mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml"
826 rel_type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
827 _id = 1
828 _path = "/xl/pivotCache/pivotCacheDefinition{0}.xml"
829 records = None
830
831 tagname = "pivotCacheDefinition"
832
833 invalid = Bool(allow_none=True)
834 saveData = Bool(allow_none=True)
835 refreshOnLoad = Bool(allow_none=True)
836 optimizeMemory = Bool(allow_none=True)
837 enableRefresh = Bool(allow_none=True)
838 refreshedBy = String(allow_none=True)
839 refreshedDate = Float(allow_none=True)
840 refreshedDateIso = DateTime(allow_none=True)
841 backgroundQuery = Bool(allow_none=True)
842 missingItemsLimit = Integer(allow_none=True)
843 createdVersion = Integer(allow_none=True)
844 refreshedVersion = Integer(allow_none=True)
845 minRefreshableVersion = Integer(allow_none=True)
846 recordCount = Integer(allow_none=True)
847 upgradeOnRefresh = Bool(allow_none=True)
848 supportSubquery = Bool(allow_none=True)
849 supportAdvancedDrill = Bool(allow_none=True)
850 cacheSource = Typed(expected_type=CacheSource)
851 cacheFields = NestedSequence(expected_type=CacheField, count=True)
852 cacheHierarchies = NestedSequence(expected_type=CacheHierarchy, allow_none=True)
853 kpis = NestedSequence(expected_type=OLAPKPI, count=True)
854 tupleCache = Typed(expected_type=TupleCache, allow_none=True)
855 calculatedItems = NestedSequence(expected_type=CalculatedItem, count=True)
856 calculatedMembers = NestedSequence(expected_type=CalculatedMember, count=True)
857 dimensions = NestedSequence(expected_type=PivotDimension, allow_none=True)
858 measureGroups = NestedSequence(expected_type=MeasureGroup, count=True)
859 maps = NestedSequence(expected_type=MeasureDimensionMap, count=True)
860 extLst = Typed(expected_type=ExtensionList, allow_none=True)
861 id = Relation()
862
863 __elements__ = ('cacheSource', 'cacheFields', 'cacheHierarchies', 'kpis',
864 'tupleCache', 'calculatedItems', 'calculatedMembers', 'dimensions',
865 'measureGroups', 'maps',)
866
867 def __init__(self,
868 invalid=None,
869 saveData=None,
870 refreshOnLoad=None,
871 optimizeMemory=None,
872 enableRefresh=None,
873 refreshedBy=None,
874 refreshedDate=None,
875 refreshedDateIso=None,
876 backgroundQuery=None,
877 missingItemsLimit=None,
878 createdVersion=None,
879 refreshedVersion=None,
880 minRefreshableVersion=None,
881 recordCount=None,
882 upgradeOnRefresh=None,
883 tupleCache=None,
884 supportSubquery=None,
885 supportAdvancedDrill=None,
886 cacheSource=None,
887 cacheFields=(),
888 cacheHierarchies=(),
889 kpis=(),
890 calculatedItems=(),
891 calculatedMembers=(),
892 dimensions=(),
893 measureGroups=(),
894 maps=(),
895 extLst=None,
896 id = None,
897 ):
898 self.invalid = invalid
899 self.saveData = saveData
900 self.refreshOnLoad = refreshOnLoad
901 self.optimizeMemory = optimizeMemory
902 self.enableRefresh = enableRefresh
903 self.refreshedBy = refreshedBy
904 self.refreshedDate = refreshedDate
905 self.refreshedDateIso = refreshedDateIso
906 self.backgroundQuery = backgroundQuery
907 self.missingItemsLimit = missingItemsLimit
908 self.createdVersion = createdVersion
909 self.refreshedVersion = refreshedVersion
910 self.minRefreshableVersion = minRefreshableVersion
911 self.recordCount = recordCount
912 self.upgradeOnRefresh = upgradeOnRefresh
913 self.supportSubquery = supportSubquery
914 self.supportAdvancedDrill = supportAdvancedDrill
915 self.cacheSource = cacheSource
916 self.cacheFields = cacheFields
917 self.cacheHierarchies = cacheHierarchies
918 self.kpis = kpis
919 self.tupleCache = tupleCache
920 self.calculatedItems = calculatedItems
921 self.calculatedMembers = calculatedMembers
922 self.dimensions = dimensions
923 self.measureGroups = measureGroups
924 self.maps = maps
925 self.id = id
926
927
928 def to_tree(self):
929 node = super().to_tree()
930 node.set("xmlns", SHEET_MAIN_NS)
931 return node
932
933
934 @property
935 def path(self):
936 return self._path.format(self._id)
937
938
939 def _write(self, archive, manifest):
940 """
941 Add to zipfile and update manifest
942 """
943 self._write_rels(archive, manifest)
944 xml = tostring(self.to_tree())
945 archive.writestr(self.path[1:], xml)
946 manifest.append(self)
947
948
949 def _write_rels(self, archive, manifest):
950 """
951 Write the relevant child objects and add links
952 """
953 if self.records is None:
954 return
955
956 rels = RelationshipList()
957 r = Relationship(Type=self.records.rel_type, Target=self.records.path)
958 rels.append(r)
959 self.id = r.id
960 self.records._id = self._id
961 self.records._write(archive, manifest)
962
963 path = get_rels_path(self.path)
964 xml = tostring(rels.to_tree())
965 archive.writestr(path[1:], xml)