class ChartSpace(Serialisable): tagname = "chartSpace" date1904 = NestedBool(allow_none=True) lang = NestedString(allow_none=True) roundedCorners = NestedBool(allow_none=True) style = NestedMinMax(allow_none=True, min=1, max=48) clrMapOvr = Typed(expected_type=ColorMapping, allow_none=True) pivotSource = Typed(expected_type=PivotSource, allow_none=True) protection = Typed(expected_type=Protection, allow_none=True) chart = Typed(expected_type=ChartContainer) spPr = Typed(expected_type=GraphicalProperties, allow_none=True) graphicalProperties = Alias("spPr") txPr = Typed(expected_type=RichText, allow_none=True) textProperties = Alias("txPr") externalData = Typed(expected_type=ExternalData, allow_none=True) printSettings = Typed(expected_type=PrintSettings, allow_none=True) userShapes = Relation() extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('date1904', 'lang', 'roundedCorners', 'style', 'clrMapOvr', 'pivotSource', 'protection', 'chart', 'spPr', 'txPr', 'externalData', 'printSettings', 'userShapes') def __init__( self, date1904=None, lang=None, roundedCorners=None, style=None, clrMapOvr=None, pivotSource=None, protection=None, chart=None, spPr=None, txPr=None, externalData=None, printSettings=None, userShapes=None, extLst=None, ): self.date1904 = date1904 self.lang = lang self.roundedCorners = roundedCorners self.style = style self.clrMapOvr = clrMapOvr self.pivotSource = pivotSource self.protection = protection self.chart = chart self.spPr = spPr self.txPr = txPr self.externalData = externalData self.printSettings = printSettings self.userShapes = userShapes def to_tree(self, tagname=None, idx=None, namespace=None): tree = super(ChartSpace, self).to_tree() tree.set("xmlns", CHART_NS) return tree
class Hyperlink(Serialisable): tagname = "hyperlink" ref = String() location = String(allow_none=True) tooltip = String(allow_none=True) display = String(allow_none=True) id = Relation() target = String(allow_none=True) __attrs__ = ("ref", "location", "tooltip", "display", "id") def __init__(self, ref=None, location=None, tooltip=None, display=None, id=None, target=None, ): self.ref = ref self.location = location self.tooltip = tooltip self.display = display self.id = id self.target = target
class Drawing(Serialisable): tagname = "drawing" id = Relation() def __init__(self, id=None): self.id = id
class ExternalReference(Serialisable): tagname = "externalReference" id = Relation() def __init__(self, id): self.id = id
class ChartRelation(Serialisable): tagname = "chart" namespace = CHART_NS id = Relation() def __init__(self, id): self.id = id
class Related(Serialisable): id = Relation() def __init__(self, id=None): self.id = id def to_tree(self, tagname, idx=None): return super(Related, self).to_tree(tagname)
class ExternalBook(Serialisable): tagname = "externalBook" sheetNames = Typed(expected_type=ExternalSheetNames, allow_none=True) definedNames = NestedSequence(expected_type=ExternalDefinedName) sheetDataSet = Typed(expected_type=ExternalSheetDataSet, allow_none=True) id = Relation() __elements__ = ('sheetNames', 'definedNames', 'sheetDataSet') def __init__(self, sheetNames=None, definedNames=(), sheetDataSet=None, id=None, ): self.sheetNames = sheetNames self.definedNames = definedNames self.sheetDataSet = sheetDataSet self.id = id
class Hyperlink(Serialisable): tagname = "hlinkClick" namespace = DRAWING_NS invalidUrl = String(allow_none=True) action = String(allow_none=True) tgtFrame = String(allow_none=True) tooltip = String(allow_none=True) history = Bool(allow_none=True) highlightClick = Bool(allow_none=True) endSnd = Bool(allow_none=True) snd = Typed(expected_type=EmbeddedWAVAudioFile, allow_none=True) extLst = Typed(expected_type=OfficeArtExtensionList, allow_none=True) id = Relation(allow_none=True) __elements__ = ('snd', ) def __init__( self, invalidUrl=None, action=None, tgtFrame=None, tooltip=None, history=None, highlightClick=None, endSnd=None, snd=None, extLst=None, id=None, ): self.invalidUrl = invalidUrl self.action = action self.tgtFrame = tgtFrame self.tooltip = tooltip self.history = history self.highlightClick = highlightClick self.endSnd = endSnd self.snd = snd self.id = id
class _AnchorBase(Serialisable): #one of sp = Typed(expected_type=Shape, allow_none=True) shape = Alias("sp") grpSp = Typed(expected_type=GroupShape, allow_none=True) groupShape = Alias("grpSp") graphicFrame = Typed(expected_type=GraphicFrame, allow_none=True) cxnSp = Typed(expected_type=Shape, allow_none=True) connectionShape = Alias("cxnSp") pic = Typed(expected_type=PictureFrame, allow_none=True) contentPart = Relation() clientData = Typed(expected_type=AnchorClientData) __elements__ = ('sp', 'grpSp', 'graphicFrame', 'cxnSp', 'pic', 'contentPart', 'clientData') def __init__(self, clientData=None, sp=None, grpSp=None, graphicFrame=None, cxnSp=None, pic=None, contentPart=None ): if clientData is None: clientData = AnchorClientData() self.clientData = clientData self.sp = sp self.grpSp = grpSp self.graphicFrame = graphicFrame self.cxnSp = cxnSp self.pic = pic self.contentPart = contentPart
class PrintPageSetup(Serialisable): """ Worksheet print page setup """ tagname = "pageSetup" orientation = NoneSet(values=("default", "portrait", "landscape")) paperSize = Integer(allow_none=True) scale = Integer(allow_none=True) fitToHeight = Integer(allow_none=True) fitToWidth = Integer(allow_none=True) firstPageNumber = Integer(allow_none=True) useFirstPageNumber = Bool(allow_none=True) paperHeight = UniversalMeasure(allow_none=True) paperWidth = UniversalMeasure(allow_none=True) pageOrder = NoneSet(values=("downThenOver", "overThenDown")) usePrinterDefaults = Bool(allow_none=True) blackAndWhite = Bool(allow_none=True) draft = Bool(allow_none=True) cellComments = NoneSet(values=("asDisplayed", "atEnd")) errors = NoneSet(values=("displayed", "blank", "dash", "NA")) horizontalDpi = Integer(allow_none=True) verticalDpi = Integer(allow_none=True) copies = Integer(allow_none=True) id = Relation() def __init__(self, worksheet=None, orientation=None, paperSize=None, scale=None, fitToHeight=None, fitToWidth=None, firstPageNumber=None, useFirstPageNumber=None, paperHeight=None, paperWidth=None, pageOrder=None, usePrinterDefaults=None, blackAndWhite=None, draft=None, cellComments=None, errors=None, horizontalDpi=None, verticalDpi=None, copies=None, id=None): self._parent = worksheet self.orientation = orientation self.paperSize = paperSize self.scale = scale self.fitToHeight = fitToHeight self.fitToWidth = fitToWidth self.firstPageNumber = firstPageNumber self.useFirstPageNumber = useFirstPageNumber self.paperHeight = paperHeight self.paperWidth = paperWidth self.pageOrder = pageOrder self.usePrinterDefaults = usePrinterDefaults self.blackAndWhite = blackAndWhite self.draft = draft self.cellComments = cellComments self.errors = errors self.horizontalDpi = horizontalDpi self.verticalDpi = verticalDpi self.copies = copies self.id = id @property def sheet_properties(self): """ Proxy property """ return self._parent.sheet_properties.pageSetUpPr @property def fitToPage(self): return self.sheet_properties.fitToPage @fitToPage.setter def fitToPage(self, value): self.sheet_properties.fitToPage = value @property def autoPageBreaks(self): return self.sheet_properties.autoPageBreaks @autoPageBreaks.setter def autoPageBreaks(self, value): self.sheet_properties.autoPageBreaks = value @classmethod def from_tree(cls, node): self = super(PrintPageSetup, cls).from_tree(node) self.id = None # strip link to binary settings return self
class SheetBackgroundPicture(Serialisable): tagname = "picture" id = Relation() def __init__(self, id): self.id = id
class DrawingHF(Serialisable): id = Relation() lho = Integer(allow_none=True) leftHeaderOddPages = Alias('lho') lhe = Integer(allow_none=True) leftHeaderEvenPages = Alias('lhe') lhf = Integer(allow_none=True) leftHeaderFirstPage = Alias('lhf') cho = Integer(allow_none=True) centerHeaderOddPages = Alias('cho') che = Integer(allow_none=True) centerHeaderEvenPages = Alias('che') chf = Integer(allow_none=True) centerHeaderFirstPage = Alias('chf') rho = Integer(allow_none=True) rightHeaderOddPages = Alias('rho') rhe = Integer(allow_none=True) rightHeaderEvenPages = Alias('rhe') rhf = Integer(allow_none=True) rightHeaderFirstPage = Alias('rhf') lfo = Integer(allow_none=True) leftFooterOddPages = Alias('lfo') lfe = Integer(allow_none=True) leftFooterEvenPages = Alias('lfe') lff = Integer(allow_none=True) leftFooterFirstPage = Alias('lff') cfo = Integer(allow_none=True) centerFooterOddPages = Alias('cfo') cfe = Integer(allow_none=True) centerFooterEvenPages = Alias('cfe') cff = Integer(allow_none=True) centerFooterFirstPage = Alias('cff') rfo = Integer(allow_none=True) rightFooterOddPages = Alias('rfo') rfe = Integer(allow_none=True) rightFooterEvenPages = Alias('rfe') rff = Integer(allow_none=True) rightFooterFirstPage = Alias('rff') def __init__( self, 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, ): self.id = id self.lho = lho self.lhe = lhe self.lhf = lhf self.cho = cho self.che = che self.chf = chf self.rho = rho self.rhe = rhe self.rhf = rhf self.lfo = lfo self.lfe = lfe self.lff = lff self.cfo = cfo self.cfe = cfe self.cff = cff self.rfo = rfo self.rfe = rfe self.rff = rff
class CacheDefinition(Serialisable): mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml" rel_type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition" _id = 1 _path = "/xl/pivotCache/pivotCacheDefinition{0}.xml" records = None tagname = "pivotCacheDefinition" invalid = Bool(allow_none=True) saveData = Bool(allow_none=True) refreshOnLoad = Bool(allow_none=True) optimizeMemory = Bool(allow_none=True) enableRefresh = Bool(allow_none=True) refreshedBy = String(allow_none=True) refreshedDate = Float(allow_none=True) refreshedDateIso = DateTime(allow_none=True) backgroundQuery = Bool(allow_none=True) missingItemsLimit = Integer(allow_none=True) createdVersion = Integer(allow_none=True) refreshedVersion = Integer(allow_none=True) minRefreshableVersion = Integer(allow_none=True) recordCount = Integer(allow_none=True) upgradeOnRefresh = Bool(allow_none=True) tupleCache = Bool(allow_none=True) supportSubquery = Bool(allow_none=True) supportAdvancedDrill = Bool(allow_none=True) cacheSource = Typed(expected_type=CacheSource) cacheFields = NestedSequence(expected_type=CacheField, count=True) cacheHierarchies = NestedSequence(expected_type=CacheHierarchy, allow_none=True) kpis = NestedSequence(expected_type=PCDKPI, allow_none=True) tupleCache = Typed(expected_type=TupleCache, allow_none=True) calculatedItems = NestedSequence(expected_type=CalculatedItem, count=True) calculatedMembers = NestedSequence(expected_type=CalculatedMember, count=True) dimensions = NestedSequence(expected_type=PivotDimension, allow_none=True) measureGroups = NestedSequence(expected_type=MeasureGroup, count=True) maps = NestedSequence(expected_type=MeasureDimensionMap, count=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) id = Relation() __elements__ = ( 'cacheSource', 'cacheFields', 'cacheHierarchies', 'kpis', 'tupleCache', 'calculatedItems', 'calculatedMembers', 'dimensions', 'measureGroups', 'maps', ) def __init__( self, invalid=None, saveData=None, refreshOnLoad=None, optimizeMemory=None, enableRefresh=None, refreshedBy=None, refreshedDate=None, refreshedDateIso=None, backgroundQuery=None, missingItemsLimit=None, createdVersion=None, refreshedVersion=None, minRefreshableVersion=None, recordCount=None, upgradeOnRefresh=None, tupleCache=None, supportSubquery=None, supportAdvancedDrill=None, cacheSource=None, cacheFields=(), cacheHierarchies=(), kpis=(), calculatedItems=(), calculatedMembers=(), dimensions=(), measureGroups=(), maps=(), extLst=None, id=None, ): self.invalid = invalid self.saveData = saveData self.refreshOnLoad = refreshOnLoad self.optimizeMemory = optimizeMemory self.enableRefresh = enableRefresh self.refreshedBy = refreshedBy self.refreshedDate = refreshedDate self.refreshedDateIso = refreshedDateIso self.backgroundQuery = backgroundQuery self.missingItemsLimit = missingItemsLimit self.createdVersion = createdVersion self.refreshedVersion = refreshedVersion self.minRefreshableVersion = minRefreshableVersion self.recordCount = recordCount self.upgradeOnRefresh = upgradeOnRefresh self.tupleCache = tupleCache self.supportSubquery = supportSubquery self.supportAdvancedDrill = supportAdvancedDrill self.cacheSource = cacheSource self.cacheFields = cacheFields self.cacheHierarchies = cacheHierarchies self.kpis = kpis self.tupleCache = tupleCache self.calculatedItems = calculatedItems self.calculatedMembers = calculatedMembers self.dimensions = dimensions self.measureGroups = measureGroups self.maps = maps self.id = id def to_tree(self): node = super(CacheDefinition, self).to_tree() node.set("xmlns", SHEET_MAIN_NS) return node @property def path(self): return self._path.format(self._id) def _write(self, archive, manifest): """ Add to zipfile and update manifest """ self._write_rels(archive, manifest) xml = tostring(self.to_tree()) archive.writestr(self.path[1:], xml) manifest.append(self) def _write_rels(self, archive, manifest): """ Write the relevant child objects and add links """ if self.records is None: return rels = RelationshipList() r = Relationship(Type=self.records.rel_type, Target=self.records.path) rels.append(r) self.id = r.id self.records._id = self._id self.records._write(archive, manifest) path = get_rels_path(self.path) xml = tostring(rels.to_tree()) archive.writestr(path[1:], xml)
class TableDefinition(Serialisable): mime_type = "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml" rel_type = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable" _id = 1 _path = "/xl/pivotTables/pivotTable{0}.xml" tagname = "pivotTableDefinition" cache = None name = String() cacheId = Integer() dataOnRows = Bool() dataPosition = Integer(allow_none=True) dataCaption = String() grandTotalCaption = String(allow_none=True) errorCaption = String(allow_none=True) showError = Bool() missingCaption = String(allow_none=True) showMissing = Bool() pageStyle = String(allow_none=True) pivotTableStyle = String(allow_none=True) vacatedStyle = String(allow_none=True) tag = String(allow_none=True) updatedVersion = Integer() minRefreshableVersion = Integer() asteriskTotals = Bool() showItems = Bool() editData = Bool() disableFieldList = Bool() showCalcMbrs = Bool() visualTotals = Bool() showMultipleLabel = Bool() showDataDropDown = Bool() showDrill = Bool() printDrill = Bool() showMemberPropertyTips = Bool() showDataTips = Bool() enableWizard = Bool() enableDrill = Bool() enableFieldProperties = Bool() preserveFormatting = Bool() useAutoFormatting = Bool() pageWrap = Integer() pageOverThenDown = Bool() subtotalHiddenItems = Bool() rowGrandTotals = Bool() colGrandTotals = Bool() fieldPrintTitles = Bool() itemPrintTitles = Bool() mergeItem = Bool() showDropZones = Bool() createdVersion = Integer() indent = Integer() showEmptyRow = Bool() showEmptyCol = Bool() showHeaders = Bool() compact = Bool() outline = Bool() outlineData = Bool() compactData = Bool() published = Bool() gridDropZones = Bool() immersive = Bool() multipleFieldFilters = Bool() chartFormat = Integer() rowHeaderCaption = String(allow_none=True) colHeaderCaption = String(allow_none=True) fieldListSortAscending = Bool() mdxSubqueries = Bool() customListSort = Bool(allow_none=True) autoFormatId = Integer(allow_none=True) applyNumberFormats = Bool() applyBorderFormats = Bool() applyFontFormats = Bool() applyPatternFormats = Bool() applyAlignmentFormats = Bool() applyWidthHeightFormats = Bool() location = Typed(expected_type=Location, ) pivotFields = NestedSequence(expected_type=PivotField, count=True) rowFields = NestedSequence(expected_type=RowColField, count=True) rowItems = NestedSequence(expected_type=RowColItem, count=True) colFields = NestedSequence(expected_type=RowColField, count=True) colItems = NestedSequence(expected_type=RowColItem, count=True) pageFields = NestedSequence(expected_type=PageField, count=True) dataFields = NestedSequence(expected_type=DataField, count=True) formats = NestedSequence(expected_type=Format, count=True) conditionalFormats = NestedSequence(expected_type=ConditionalFormat, count=True) chartFormats = NestedSequence(expected_type=ChartFormat, count=True) pivotHierarchies = NestedSequence(expected_type=PivotHierarchy, count=True) pivotTableStyleInfo = Typed(expected_type=PivotTableStyle, allow_none=True) filters = NestedSequence(expected_type=PivotFilter, count=True) rowHierarchiesUsage = Typed(expected_type=RowHierarchiesUsage, allow_none=True) colHierarchiesUsage = Typed(expected_type=ColHierarchiesUsage, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) id = Relation() __elements__ = ( 'location', 'pivotFields', 'rowFields', 'rowItems', 'colFields', 'colItems', 'pageFields', 'dataFields', 'formats', 'conditionalFormats', 'chartFormats', 'pivotHierarchies', 'pivotTableStyleInfo', 'filters', 'rowHierarchiesUsage', 'colHierarchiesUsage', ) def __init__( self, name=None, cacheId=None, dataOnRows=False, dataPosition=None, dataCaption=None, grandTotalCaption=None, errorCaption=None, showError=False, missingCaption=None, showMissing=True, pageStyle=None, pivotTableStyle=None, vacatedStyle=None, tag=None, updatedVersion=0, minRefreshableVersion=0, asteriskTotals=False, showItems=True, editData=False, disableFieldList=False, showCalcMbrs=True, visualTotals=True, showMultipleLabel=True, showDataDropDown=True, showDrill=True, printDrill=False, showMemberPropertyTips=True, showDataTips=True, enableWizard=True, enableDrill=True, enableFieldProperties=True, preserveFormatting=True, useAutoFormatting=False, pageWrap=0, pageOverThenDown=False, subtotalHiddenItems=False, rowGrandTotals=True, colGrandTotals=True, fieldPrintTitles=False, itemPrintTitles=False, mergeItem=False, showDropZones=True, createdVersion=0, indent=1, showEmptyRow=False, showEmptyCol=False, showHeaders=True, compact=True, outline=False, outlineData=False, compactData=True, published=False, gridDropZones=False, immersive=True, multipleFieldFilters=None, chartFormat=0, rowHeaderCaption=None, colHeaderCaption=None, fieldListSortAscending=None, mdxSubqueries=None, customListSort=None, autoFormatId=None, applyNumberFormats=False, applyBorderFormats=False, applyFontFormats=False, applyPatternFormats=False, applyAlignmentFormats=False, applyWidthHeightFormats=False, location=None, pivotFields=(), rowFields=(), rowItems=(), colFields=(), colItems=(), pageFields=(), dataFields=(), formats=(), conditionalFormats=(), chartFormats=(), pivotHierarchies=(), pivotTableStyleInfo=None, filters=(), rowHierarchiesUsage=None, colHierarchiesUsage=None, extLst=None, id=None, ): self.name = name self.cacheId = cacheId self.dataOnRows = dataOnRows self.dataPosition = dataPosition self.dataCaption = dataCaption self.grandTotalCaption = grandTotalCaption self.errorCaption = errorCaption self.showError = showError self.missingCaption = missingCaption self.showMissing = showMissing self.pageStyle = pageStyle self.pivotTableStyle = pivotTableStyle self.vacatedStyle = vacatedStyle self.tag = tag self.updatedVersion = updatedVersion self.minRefreshableVersion = minRefreshableVersion self.asteriskTotals = asteriskTotals self.showItems = showItems self.editData = editData self.disableFieldList = disableFieldList self.showCalcMbrs = showCalcMbrs self.visualTotals = visualTotals self.showMultipleLabel = showMultipleLabel self.showDataDropDown = showDataDropDown self.showDrill = showDrill self.printDrill = printDrill self.showMemberPropertyTips = showMemberPropertyTips self.showDataTips = showDataTips self.enableWizard = enableWizard self.enableDrill = enableDrill self.enableFieldProperties = enableFieldProperties self.preserveFormatting = preserveFormatting self.useAutoFormatting = useAutoFormatting self.pageWrap = pageWrap self.pageOverThenDown = pageOverThenDown self.subtotalHiddenItems = subtotalHiddenItems self.rowGrandTotals = rowGrandTotals self.colGrandTotals = colGrandTotals self.fieldPrintTitles = fieldPrintTitles self.itemPrintTitles = itemPrintTitles self.mergeItem = mergeItem self.showDropZones = showDropZones self.createdVersion = createdVersion self.indent = indent self.showEmptyRow = showEmptyRow self.showEmptyCol = showEmptyCol self.showHeaders = showHeaders self.compact = compact self.outline = outline self.outlineData = outlineData self.compactData = compactData self.published = published self.gridDropZones = gridDropZones self.immersive = immersive self.multipleFieldFilters = multipleFieldFilters self.chartFormat = chartFormat self.rowHeaderCaption = rowHeaderCaption self.colHeaderCaption = colHeaderCaption self.fieldListSortAscending = fieldListSortAscending self.mdxSubqueries = mdxSubqueries self.customListSort = customListSort self.autoFormatId = autoFormatId self.applyNumberFormats = applyNumberFormats self.applyBorderFormats = applyBorderFormats self.applyFontFormats = applyFontFormats self.applyPatternFormats = applyPatternFormats self.applyAlignmentFormats = applyAlignmentFormats self.applyWidthHeightFormats = applyWidthHeightFormats self.location = location self.pivotFields = pivotFields self.rowFields = rowFields self.rowItems = rowItems self.colFields = colFields self.colItems = colItems self.pageFields = pageFields self.dataFields = dataFields self.formats = formats self.conditionalFormats = conditionalFormats self.chartFormats = chartFormats self.pivotHierarchies = pivotHierarchies self.pivotTableStyleInfo = pivotTableStyleInfo self.filters = filters self.rowHierarchiesUsage = rowHierarchiesUsage self.colHierarchiesUsage = colHierarchiesUsage self.extLst = extLst self.id = id def to_tree(self): tree = super(TableDefinition, self).to_tree() tree.set("xmlns", SHEET_MAIN_NS) return tree @property def path(self): return self._path.format(self._id) def _write(self, archive, manifest): """ Add to zipfile and update manifest """ self._write_rels(archive, manifest) xml = tostring(self.to_tree()) archive.writestr(self.path[1:], xml) manifest.append(self) def _write_rels(self, archive, manifest): """ Write the relevant child objects and add links """ if self.cache is None: return rels = RelationshipList() r = Relationship(Type=self.cache.rel_type, Target=self.cache.path) rels.append(r) self.id = r.id if self.cache.path[1:] not in archive.namelist(): self.cache._write(archive, manifest) path = get_rels_path(self.path) xml = tostring(rels.to_tree()) archive.writestr(path[1:], xml)