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 ServerFormat(Serialisable): tagname = "serverFormat" format = String(allow_none=True) def __init__( self, culture=None, format=None, ): self.culture = culture self.format = format
class Number(Serialisable): tagname = "n" tpls = Sequence(expected_type=TupleList) x = Sequence(expected_type=Index) v = Float() u = Bool(allow_none=True) f = Bool(allow_none=True) c = String(allow_none=True) cp = Integer(allow_none=True) _in = Integer(allow_none=True) bc = HexBinary(allow_none=True) fc = HexBinary(allow_none=True) i = Bool(allow_none=True) un = Bool(allow_none=True) st = Bool(allow_none=True) b = Bool(allow_none=True) __elements__ = ('tpls', 'x') def __init__(self, tpls=(), x=(), v=None, u=None, f=None, c=None, cp=None, _in=None, bc=None, fc=None, i=None, un=None, st=None, b=None, ): self.tpls = tpls self.x = x self.v = v self.u = u self.f = f self.c = c self.cp = cp self._in = _in self.bc = bc self.fc = fc self.i = i self.un = un self.st = st self.b = b
class FileVersion(Serialisable): tagname = "fileVersion" appName = String(allow_none=True) lastEdited = String(allow_none=True) lowestEdited = String(allow_none=True) rupBuild = String(allow_none=True) codeName = Guid(allow_none=True) def __init__( self, appName=None, lastEdited=None, lowestEdited=None, rupBuild=None, codeName=None, ): self.appName = appName self.lastEdited = lastEdited self.lowestEdited = lowestEdited self.rupBuild = rupBuild self.codeName = codeName
class GroupMember(Serialisable): tagname = "groupMember" uniqueName = String() group = Bool() def __init__( self, uniqueName=None, group=None, ): self.uniqueName = uniqueName self.group = group
class TextField(Serialisable): id = String() type = String(allow_none=True) rPr = Typed(expected_type=CharacterProperties, allow_none=True) pPr = Typed(expected_type=ParagraphProperties, allow_none=True) t = String(allow_none=True) __elements__ = ('rPr', 'pPr') def __init__( self, id=None, type=None, rPr=None, pPr=None, t=None, ): self.id = id self.type = type self.rPr = rPr self.pPr = pPr self.t = t
class Trendline(Serialisable): tagname = "trendline" name = String(allow_none=True) spPr = Typed(expected_type=GraphicalProperties, allow_none=True) graphicalProperties = Alias('spPr') trendlineType = NestedSet( values=(['exp', 'linear', 'log', 'movingAvg', 'poly', 'power'])) order = NestedInteger(allow_none=True) period = NestedInteger(allow_none=True) forward = NestedFloat(allow_none=True) backward = NestedFloat(allow_none=True) intercept = NestedFloat(allow_none=True) dispRSqr = NestedBool(allow_none=True) dispEq = NestedBool(allow_none=True) trendlineLbl = Typed(expected_type=TrendlineLabel, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('name', 'spPr', 'trendlineType', 'order', 'period', 'forward', 'backward', 'intercept', 'dispRSqr', 'dispEq', 'trendlineLbl') def __init__( self, name=None, spPr=None, trendlineType='linear', order=None, period=None, forward=None, backward=None, intercept=None, dispRSqr=None, dispEq=None, trendlineLbl=None, extLst=None, ): self.name = name self.spPr = spPr self.trendlineType = trendlineType self.order = order self.period = period self.forward = forward self.backward = backward self.intercept = intercept self.dispRSqr = dispRSqr self.dispEq = dispEq self.trendlineLbl = trendlineLbl
class GraphicData(Serialisable): tagname = "graphicData" namespace = DRAWING_NS uri = String() chart = Typed(expected_type=ChartRelation, allow_none=True) def __init__( self, uri=CHART_NS, chart=None, ): self.uri = uri self.chart = chart
class XMLColumnProps(Serialisable): tagname = "xmlColumnPr" mapId = Integer() xpath = String() denormalized = Bool(allow_none=True) xmlDataType = String() extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = () def __init__( self, mapId=None, xpath=None, denormalized=None, xmlDataType=None, extLst=None, ): self.mapId = mapId self.xpath = xpath self.denormalized = denormalized self.xmlDataType = xmlDataType
class SheetDimension(Serialisable): tagname = "dimension" ref = String() def __init__( self, ref=None, ): self.ref = ref @property def boundaries(self): return range_boundaries(self.ref)
class Query(Serialisable): tagname = "query" mdx = String() tpls = Typed(expected_type=TupleList, allow_none=True) __elements__ = ('tpls', ) def __init__( self, mdx=None, tpls=None, ): self.mdx = mdx self.tpls = tpls
class CustomFilter(Serialisable): tagname = "customFilter" operator = NoneSet(values=([ 'equal', 'lessThan', 'lessThanOrEqual', 'notEqual', 'greaterThanOrEqual', 'greaterThan' ])) val = String() def __init__( self, operator=None, val=None, ): self.operator = operator self.val = val
class ExternalCell(Serialisable): r = String() t = NoneSet(values=(['b', 'd', 'n', 'e', 's', 'str', 'inlineStr'])) vm = Integer(allow_none=True) v = NestedText(allow_none=True, expected_type=unicode) def __init__(self, r=None, t=None, vm=None, v=None, ): self.r = r self.t = t self.vm = vm self.v = v
class FieldItem(Serialisable): tagname = "item" n = String(allow_none=True) t = Set(values=([ 'data', 'default', 'sum', 'countA', 'avg', 'max', 'min', 'product', 'count', 'stdDev', 'stdDevP', 'var', 'varP', 'grand', 'blank' ])) h = Bool(allow_none=True) s = Bool(allow_none=True) sd = Bool(allow_none=True) f = Bool(allow_none=True) m = Bool(allow_none=True) c = Bool(allow_none=True) x = Integer(allow_none=True) d = Bool(allow_none=True) e = Bool(allow_none=True) def __init__( self, n=None, t="data", h=None, s=None, sd=True, f=None, m=None, c=None, x=None, d=None, e=None, ): self.n = n self.t = t self.h = h self.s = s self.sd = sd self.f = f self.m = m self.c = c self.x = x self.d = d self.e = e
class Font(Serialisable): tagname = "latin" namespace = DRAWING_NS typeface = String() panose = HexBinary(allow_none=True) pitchFamily = MinMax(min=0, max=52, allow_none=True) charset = Integer(allow_none=True) def __init__( self, typeface=None, panose=None, pitchFamily=None, charset=None, ): self.typeface = typeface self.panose = panose self.pitchFamily = pitchFamily self.charset = charset
class DataField(Serialisable): tagname = "dataField" name = String(allow_none=True) fld = Integer() subtotal = Set(values=([ 'average', 'count', 'countNums', 'max', 'min', 'product', 'stdDev', 'stdDevp', 'sum', 'var', 'varp' ])) showDataAs = Set(values=([ 'normal', 'difference', 'percent', 'percentDiff', 'runTotal', 'percentOfRow', 'percentOfCol', 'percentOfTotal', 'index' ])) baseField = Integer() baseItem = Integer() numFmtId = Integer(allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = () def __init__( self, name=None, fld=None, subtotal="sum", showDataAs="normal", baseField=-1, baseItem=1048832, numFmtId=None, extLst=None, ): self.name = name self.fld = fld self.subtotal = subtotal self.showDataAs = showDataAs self.baseField = baseField self.baseItem = baseItem self.numFmtId = numFmtId self.extLst = extLst
class ConnectorShape(Serialisable): tagname = "cxnSp" nvCxnSpPr = Typed(expected_type=ConnectorNonVisual) spPr = Typed(expected_type=GraphicalProperties) style = Typed(expected_type=ShapeStyle, allow_none=True) macro = String(allow_none=True) fPublished = Bool(allow_none=True) def __init__(self, nvCxnSpPr=None, spPr=None, style=None, macro=None, fPublished=None, ): self.nvCxnSpPr = nvCxnSpPr self.spPr = spPr self.style = style self.macro = macro self.fPublished = fPublished
class CalculatedItem(Serialisable): tagname = "calculatedItem" field = Integer(allow_none=True) formula = String() pivotArea = Typed(expected_type=PivotArea, ) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('pivotArea', 'extLst') def __init__( self, field=None, formula=None, pivotArea=None, extLst=None, ): self.field = field self.formula = formula self.pivotArea = pivotArea self.extLst = extLst
class WebPublishing(Serialisable): tagname = "webPublishing" css = Bool(allow_none=True) thicket = Bool(allow_none=True) longFileNames = Bool(allow_none=True) vml = Bool(allow_none=True) allowPng = Bool(allow_none=True) targetScreenSize = NoneSet(values=([ '544x376', '640x480', '720x512', '800x600', '1024x768', '1152x882', '1152x900', '1280x1024', '1600x1200', '1800x1440', '1920x1200' ])) dpi = Integer(allow_none=True) codePage = Integer(allow_none=True) characterSet = String(allow_none=True) def __init__( self, css=None, thicket=None, longFileNames=None, vml=None, allowPng=None, targetScreenSize='800x600', dpi=None, codePage=None, characterSet=None, ): self.css = css self.thicket = thicket self.longFileNames = longFileNames self.vml = vml self.allowPng = allowPng self.targetScreenSize = targetScreenSize self.dpi = dpi self.codePage = codePage self.characterSet = characterSet
class TableStyleInfo(Serialisable): tagname = "tableStyleInfo" name = String(allow_none=True) showFirstColumn = Bool(allow_none=True) showLastColumn = Bool(allow_none=True) showRowStripes = Bool(allow_none=True) showColumnStripes = Bool(allow_none=True) def __init__( self, name=None, showFirstColumn=None, showLastColumn=None, showRowStripes=None, showColumnStripes=None, ): self.name = name self.showFirstColumn = showFirstColumn self.showLastColumn = showLastColumn self.showRowStripes = showRowStripes self.showColumnStripes = showColumnStripes
class _NamedCellStyle(Serialisable): """ Pointer-based representation of named styles in XML xfId refers to the corresponding CellStyleXfs Not used in client code. """ tagname = "cellStyle" name = String() xfId = Integer() builtinId = Integer(allow_none=True) iLevel = Integer(allow_none=True) hidden = Bool(allow_none=True) customBuiltin = Bool(allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = () def __init__( self, name=None, xfId=None, builtinId=None, iLevel=None, hidden=None, customBuiltin=None, extLst=None, ): self.name = name self.xfId = xfId self.builtinId = builtinId self.iLevel = iLevel self.hidden = hidden self.customBuiltin = customBuiltin
class NamedStyle(Serialisable): """ Named and editable styles """ font = Typed(expected_type=Font) fill = Typed(expected_type=Fill) border = Typed(expected_type=Border) alignment = Typed(expected_type=Alignment) number_format = NumberFormatDescriptor() protection = Typed(expected_type=Protection) builtinId = Integer(allow_none=True) hidden = Bool(allow_none=True) xfId = Integer(allow_none=True) name = String() _wb = None _style = StyleArray() def __init__( self, name="Normal", font=Font(), fill=PatternFill(), border=Border(), alignment=Alignment(), number_format=None, protection=Protection(), builtinId=None, hidden=False, xfId=None, ): self.name = name self.font = font self.fill = fill self.border = border self.alignment = alignment self.number_format = number_format self.protection = protection self.builtinId = builtinId self.hidden = hidden self._wb = None self._style = StyleArray() def __setattr__(self, attr, value): super(NamedStyle, self).__setattr__(attr, value) if getattr(self, '_wb', None) and attr in ( 'font', 'fill', 'border', 'alignment', 'number_format', 'protection', ): self._recalculate() def __iter__(self): for key in ('name', 'builtinId', 'hidden', 'xfId'): value = getattr(self, key, None) if value is not None: yield key, safe_string(value) @property def xfId(self): """ Index of the style in the list of named styles """ return self._style.xfId def _set_index(self, idx): """ Allow the containing list to set the index """ self._style.xfId = idx def bind(self, wb): """ Bind a named style to a workbook """ self._wb = wb self._recalculate() def _recalculate(self): self._style.fontId = self._wb._fonts.add(self.font) self._style.borderId = self._wb._borders.add(self.border) self._style.fillId = self._wb._fills.add(self.fill) self._style.protectionId = self._wb._protections.add(self.protection) self._style.alignmentId = self._wb._alignments.add(self.alignment) fmt = self.number_format if fmt in BUILTIN_FORMATS_REVERSE: fmt = BUILTIN_FORMATS_REVERSE[fmt] else: fmt = self._wb._number_formats.add(self.number_format) + 164 self._style.numFmtId = fmt def as_tuple(self): """Return a style array representing the current style""" return self._style def as_xf(self): """ Return equivalent XfStyle """ xf = CellStyle.from_array(self._style) xf.xfId = None xf.pivotButton = None xf.quotePrefix = None if self.alignment != Alignment(): xf.alignment = self.alignment if self.protection != Protection(): xf.protection = self.protection return xf def as_name(self): """ Return relevant named style """ named = _NamedCellStyle(name=self.name, builtinId=self.builtinId, hidden=self.hidden, xfId=self.xfId) return named
class Reference(Strict): """ Normalise cell range references """ min_row = MinMax(min=1, max=1000000, expected_type=int) max_row = MinMax(min=1, max=1000000, expected_type=int) min_col = MinMax(min=1, max=16384, expected_type=int) max_col = MinMax(min=1, max=16384, expected_type=int) range_string = String(allow_none=True) def __init__(self, worksheet=None, min_col=None, min_row=None, max_col=None, max_row=None, range_string=None ): if range_string is not None: sheetname, boundaries = range_to_tuple(range_string) min_col, min_row, max_col, max_row = boundaries worksheet = DummyWorksheet(sheetname) self.worksheet = worksheet self.min_col = min_col self.min_row = min_row if max_col is None: max_col = min_col self.max_col = max_col if max_row is None: max_row = min_row self.max_row = max_row def __repr__(self): return unicode(self) def __str__(self): fmt = u"{0}!${1}${2}:${3}${4}" if (self.min_col == self.max_col and self.min_row == self.max_row): fmt = u"{0}!${1}${2}" return fmt.format(self.sheetname, get_column_letter(self.min_col), self.min_row, get_column_letter(self.max_col), self.max_row ) __unicode__ = __str__ def __len__(self): if self.min_row == self.max_row: return 1 + self.max_col - self.min_col return 1 + self.max_row - self.min_row @property def rows(self): """ Return all cells in range by column """ for row in range(self.min_row, self.max_row+1): yield tuple('%s%d' % (get_column_letter(col), row) for col in range(self.min_col, self.max_col+1)) @property def cols(self): """ Return all cells in range by row """ for col in range(self.min_col, self.max_col+1): yield tuple('%s%d' % (get_column_letter(col), row) for row in range(self.min_row, self.max_row+1)) @property def cells(self): """ Return a flattened list of all cells (by column) """ return chain.from_iterable(self.cols) def pop(self): """ Return and remove the first cell """ cell = next(self.cells) if self.min_row == self.max_row: self.min_col += 1 else: self.min_row += 1 return cell @property def sheetname(self): return quote_sheetname(self.worksheet.title)
class ColumnDimension(Dimension): """Information about the display properties of a column.""" width = Float(allow_none=True) bestFit = Bool() auto_size = Alias('bestFit') index = String() min = Integer(allow_none=True) max = Integer(allow_none=True) collapsed = Bool() __fields__ = Dimension.__fields__ + ('width', 'bestFit', 'customWidth', 'style', 'min', 'max') def __init__( self, worksheet, index='A', width=None, bestFit=False, hidden=False, outlineLevel=0, outline_level=None, collapsed=False, style=None, min=None, max=None, customWidth=False, # do not write visible=None, auto_size=None, ): self.width = width self.min = min self.max = max if visible is not None: hidden = not visible if auto_size is not None: bestFit = auto_size self.bestFit = bestFit if outline_level is not None: outlineLevel = outline_level self.collapsed = collapsed super(ColumnDimension, self).__init__(index, hidden, outlineLevel, collapsed, worksheet, style=style) @property def customWidth(self): """Always true if there is a width for the column""" return self.width is not None def reindex(self): """ Set boundaries for column definition """ if not all([self.min, self.max]): self.min = self.max = column_index_from_string(self.index) def to_tree(self): attrs = dict(self) if set(attrs) != set(['min', 'max']): return Element("col", **attrs)
class CacheField(Serialisable): tagname = "cacheField" sharedItems = Typed(expected_type=SharedItems, allow_none=True) fieldGroup = Typed(expected_type=FieldGroup, allow_none=True) mpMap = NestedInteger(allow_none=True, attribute="v") extLst = Typed(expected_type=ExtensionList, allow_none=True) name = String() caption = String(allow_none=True) propertyName = String(allow_none=True) serverField = Bool(allow_none=True) uniqueList = Bool(allow_none=True) numFmtId = Integer(allow_none=True) formula = String(allow_none=True) sqlType = Integer(allow_none=True) hierarchy = Integer(allow_none=True) level = Integer(allow_none=True) databaseField = Bool(allow_none=True) mappingCount = Integer(allow_none=True) memberPropertyField = Bool(allow_none=True) __elements__ = ('sharedItems', 'fieldGroup', 'mpMap') def __init__( self, sharedItems=None, fieldGroup=None, mpMap=None, extLst=None, name=None, caption=None, propertyName=None, serverField=None, uniqueList=True, numFmtId=None, formula=None, sqlType=0, hierarchy=0, level=0, databaseField=True, mappingCount=None, memberPropertyField=None, ): self.sharedItems = sharedItems self.fieldGroup = fieldGroup self.mpMap = mpMap self.extLst = extLst self.name = name self.caption = caption self.propertyName = propertyName self.serverField = serverField self.uniqueList = uniqueList self.numFmtId = numFmtId self.formula = formula self.sqlType = sqlType self.hierarchy = hierarchy self.level = level self.databaseField = databaseField self.mappingCount = mappingCount self.memberPropertyField = memberPropertyField
class CacheHierarchy(Serialisable): tagname = "cacheHierarchy" uniqueName = String() caption = String(allow_none=True) measure = Bool() set = Bool() parentSet = Integer(allow_none=True) iconSet = Integer() attribute = Bool() time = Bool() keyAttribute = Bool() defaultMemberUniqueName = String(allow_none=True) allUniqueName = String(allow_none=True) allCaption = String(allow_none=True) dimensionUniqueName = String(allow_none=True) displayFolder = String(allow_none=True) measureGroup = String(allow_none=True) measures = Bool() count = Integer() oneField = Bool() memberValueDatatype = Integer(allow_none=True) unbalanced = Bool(allow_none=True) unbalancedGroup = Bool(allow_none=True) hidden = Bool() fieldsUsage = Typed(expected_type=FieldsUsage, allow_none=True) groupLevels = Typed(expected_type=GroupLevels, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('fieldsUsage', 'groupLevels') def __init__( self, uniqueName="", caption=None, measure=None, set=None, parentSet=None, iconSet=0, attribute=None, time=None, keyAttribute=None, defaultMemberUniqueName=None, allUniqueName=None, allCaption=None, dimensionUniqueName=None, displayFolder=None, measureGroup=None, measures=None, count=None, oneField=None, memberValueDatatype=None, unbalanced=None, unbalancedGroup=None, hidden=None, fieldsUsage=None, groupLevels=None, extLst=None, ): self.uniqueName = uniqueName self.caption = caption self.measure = measure self.set = set self.parentSet = parentSet self.iconSet = iconSet self.attribute = attribute self.time = time self.keyAttribute = keyAttribute self.defaultMemberUniqueName = defaultMemberUniqueName self.allUniqueName = allUniqueName self.allCaption = allCaption self.dimensionUniqueName = dimensionUniqueName self.displayFolder = displayFolder self.measureGroup = measureGroup self.measures = measures self.count = count self.oneField = oneField self.memberValueDatatype = memberValueDatatype self.unbalanced = unbalanced self.unbalancedGroup = unbalancedGroup self.hidden = hidden self.fieldsUsage = fieldsUsage self.groupLevels = groupLevels self.extLst = extLst
class PCDKPI(Serialisable): tagname = "pCDKPI" uniqueName = String() caption = String(allow_none=True) displayFolder = String() measureGroup = String() parent = String() value = String() goal = String() status = String() trend = String() weight = String() time = String() def __init__( self, uniqueName=None, caption=None, displayFolder=None, measureGroup=None, parent=None, value=None, goal=None, status=None, trend=None, weight=None, time=None, ): self.uniqueName = uniqueName self.caption = caption self.displayFolder = displayFolder self.measureGroup = measureGroup self.parent = parent self.value = value self.goal = goal self.status = status self.trend = trend self.weight = weight self.time = time
class PivotFilter(Serialisable): tagname = "filter" fld = Integer() mpFld = Integer(allow_none=True) type = Set(values=([ 'unknown', 'count', 'percent', 'sum', 'captionEqual', 'captionNotEqual', 'captionBeginsWith', 'captionNotBeginsWith', 'captionEndsWith', 'captionNotEndsWith', 'captionContains', 'captionNotContains', 'captionGreaterThan', 'captionGreaterThanOrEqual', 'captionLessThan', 'captionLessThanOrEqual', 'captionBetween', 'captionNotBetween', 'valueEqual', 'valueNotEqual', 'valueGreaterThan', 'valueGreaterThanOrEqual', 'valueLessThan', 'valueLessThanOrEqual', 'valueBetween', 'valueNotBetween', 'dateEqual', 'dateNotEqual', 'dateOlderThan', 'dateOlderThanOrEqual', 'dateNewerThan', 'dateNewerThanOrEqual', 'dateBetween', 'dateNotBetween', 'tomorrow', 'today', 'yesterday', 'nextWeek', 'thisWeek', 'lastWeek', 'nextMonth', 'thisMonth', 'lastMonth', 'nextQuarter', 'thisQuarter', 'lastQuarter', 'nextYear', 'thisYear', 'lastYear', 'yearToDate', 'Q1', 'Q2', 'Q3', 'Q4', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'M10', 'M11', 'M12' ])) evalOrder = Integer(allow_none=True) id = Integer() iMeasureHier = Integer(allow_none=True) iMeasureFld = Integer(allow_none=True) name = String(allow_none=True) description = String(allow_none=True) stringValue1 = String(allow_none=True) stringValue2 = String(allow_none=True) autoFilter = Typed(expected_type=AutoFilter, ) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('autoFilter', ) def __init__( self, fld=None, mpFld=None, type=None, evalOrder=None, id=None, iMeasureHier=None, iMeasureFld=None, name=None, description=None, stringValue1=None, stringValue2=None, autoFilter=None, extLst=None, ): self.fld = fld self.mpFld = mpFld self.type = type self.evalOrder = evalOrder self.id = id self.iMeasureHier = iMeasureHier self.iMeasureFld = iMeasureFld self.name = name self.description = description self.stringValue1 = stringValue1 self.stringValue2 = stringValue2 self.autoFilter = autoFilter
class WorkbookProtection(Serialisable): _workbook_password, _revisions_password = None, None tagname = "workbookPr" workbook_password = Alias("workbookPassword") workbookPasswordCharacterSet = String(allow_none=True) revision_password = Alias("revisionsPassword") revisionsPasswordCharacterSet = String(allow_none=True) lockStructure = Bool(allow_none=True) lock_structure = Alias("lockStructure") lockWindows = Bool(allow_none=True) lock_windows = Alias("lockWindows") lockRevision = Bool(allow_none=True) lock_revision = Alias("lockRevision") revisionsAlgorithmName = String(allow_none=True) revisionsHashValue = Base64Binary(allow_none=True) revisionsSaltValue = Base64Binary(allow_none=True) revisionsSpinCount = Integer(allow_none=True) workbookAlgorithmName = String(allow_none=True) workbookHashValue = Base64Binary(allow_none=True) workbookSaltValue = Base64Binary(allow_none=True) workbookSpinCount = Integer(allow_none=True) __attrs__ = ('workbookPassword', 'workbookPasswordCharacterSet', 'revisionsPassword', 'revisionsPasswordCharacterSet', 'lockStructure', 'lockWindows', 'lockRevision', 'revisionsAlgorithmName', 'revisionsHashValue', 'revisionsSaltValue', 'revisionsSpinCount', 'workbookAlgorithmName', 'workbookHashValue', 'workbookSaltValue', 'workbookSpinCount') def __init__( self, workbookPassword=None, workbookPasswordCharacterSet=None, revisionsPassword=None, revisionsPasswordCharacterSet=None, lockStructure=None, lockWindows=None, lockRevision=None, revisionsAlgorithmName=None, revisionsHashValue=None, revisionsSaltValue=None, revisionsSpinCount=None, workbookAlgorithmName=None, workbookHashValue=None, workbookSaltValue=None, workbookSpinCount=None, ): if workbookPassword is not None: self.workbookPassword = workbookPassword self.workbookPasswordCharacterSet = workbookPasswordCharacterSet if revisionsPassword is not None: self.revisionsPassword = revisionsPassword self.revisionsPasswordCharacterSet = revisionsPasswordCharacterSet self.lockStructure = lockStructure self.lockWindows = lockWindows self.lockRevision = lockRevision self.revisionsAlgorithmName = revisionsAlgorithmName self.revisionsHashValue = revisionsHashValue self.revisionsSaltValue = revisionsSaltValue self.revisionsSpinCount = revisionsSpinCount self.workbookAlgorithmName = workbookAlgorithmName self.workbookHashValue = workbookHashValue self.workbookSaltValue = workbookSaltValue self.workbookSpinCount = workbookSpinCount def set_workbook_password(self, value='', already_hashed=False): """Set a password on this workbook.""" if not already_hashed: value = hash_password(value) self._workbook_password = value @property def workbookPassword(self): """Return the workbook password value, regardless of hash.""" return self._workbook_password @workbookPassword.setter def workbookPassword(self, value): """Set a workbook password directly, forcing a hash step.""" self.set_workbook_password(value) def set_revisions_password(self, value='', already_hashed=False): """Set a revision password on this workbook.""" if not already_hashed: value = hash_password(value) self._revisions_password = value @property def revisionsPassword(self): """Return the revisions password value, regardless of hash.""" return self._revisions_password @revisionsPassword.setter def revisionsPassword(self, value): """Set a revisions password directly, forcing a hash step.""" self.set_revisions_password(value) @classmethod def from_tree(cls, node): """Don't hash passwords when deserialising from XML""" self = super(WorkbookProtection, cls).from_tree(node) if self.workbookPassword: self.set_workbook_password(node.get('workbookPassword'), already_hashed=True) if self.revisionsPassword: self.set_revisions_password(node.get('revisionsPassword'), already_hashed=True) return self
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)