class DateTimeField(Serialisable): tagname = "d" x = Sequence(expected_type=Index) v = DateTime() u = Bool(allow_none=True) f = Bool(allow_none=True) c = String(allow_none=True) cp = Integer(allow_none=True) __elements__ = ('x', ) def __init__( self, x=(), v=None, u=None, f=None, c=None, cp=None, ): self.x = x self.v = v self.u = u self.f = f self.c = c self.cp = cp
class TableStyle(Serialisable): tagname = "tableStyle" name = String() pivot = Bool(allow_none=True) table = Bool(allow_none=True) count = Integer(allow_none=True) tableStyleElement = Typed(expected_type=TableStyleElement, allow_none=True) __elements__ = ('tableStyleElement', ) def __init__( self, name=None, pivot=None, table=None, count=None, tableStyleElement=None, ): self.name = name self.pivot = pivot self.table = table self.count = count self.tableStyleElement = tableStyleElement
class Border(Serialisable): """Border positioning for use in styles.""" tagname = "border" __fields__ = ('left', 'right', 'top', 'bottom', 'diagonal', 'diagonal_direction', 'vertical', 'horizontal') __elements__ = ('start', 'end', 'left', 'right', 'top', 'bottom', 'diagonal', 'vertical', 'horizontal') # child elements start = Typed(expected_type=Side, allow_none=True) end = Typed(expected_type=Side, allow_none=True) left = Typed(expected_type=Side, allow_none=True) right = Typed(expected_type=Side, allow_none=True) top = Typed(expected_type=Side, allow_none=True) bottom = Typed(expected_type=Side) diagonal = Typed(expected_type=Side, allow_none=True) vertical = Typed(expected_type=Side, allow_none=True) horizontal = Typed(expected_type=Side, allow_none=True) # attributes outline = Bool() diagonalUp = Bool() diagonalDown = Bool() def __init__(self, left=Side(), right=Side(), top=Side(), bottom=Side(), diagonal=Side(), diagonal_direction=None, vertical=None, horizontal=None, diagonalUp=False, diagonalDown=False, outline=True, start=None, end=None): self.left = left self.right = right self.top = top self.bottom = bottom self.diagonal = diagonal self.vertical = vertical self.horizontal = horizontal self.diagonal_direction = diagonal_direction self.diagonalUp = diagonalUp self.diagonalDown = diagonalDown self.outline = outline self.start = start self.end = end def __iter__(self): for attr in self.__attrs__: value = getattr(self, attr) if value and attr != "outline": yield attr, safe_string(value) elif attr == "outline" and not value: yield attr, safe_string(value)
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 RangePr(Serialisable): tagname = "rangePr" autoStart = Bool(allow_none=True) autoEnd = Bool(allow_none=True) groupBy = Set(values=(['range', 'seconds', 'minutes', 'hours', 'days', 'months', 'quarters', 'years'])) startNum = Float(allow_none=True) endNum = Float(allow_none=True) startDate = DateTime(allow_none=True) endDate = DateTime(allow_none=True) groupInterval = Float(allow_none=True) def __init__(self, autoStart=True, autoEnd=True, groupBy=range, startNum=None, endNum=None, startDate=None, endDate=None, groupInterval=1, ): self.autoStart = autoStart self.autoEnd = autoEnd self.groupBy = groupBy self.startNum = startNum self.endNum = endNum self.startDate = startDate self.endDate = endDate self.groupInterval = groupInterval
class GroupLevel(Serialisable): tagname = "groupLevel" uniqueName = String() caption = String() user = Bool() customRollUp = Bool() groups = Typed(expected_type=Groups, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('groups', 'extLst') def __init__(self, uniqueName=None, caption=None, user=None, customRollUp=None, groups=None, extLst=None, ): self.uniqueName = uniqueName self.caption = caption self.user = user self.customRollUp = customRollUp self.groups = groups self.extLst = extLst
class ChartsheetProtection(Serialisable, _Protected): tagname = "sheetProtection" algorithmName = String(allow_none=True) hashValue = Base64Binary(allow_none=True) saltValue = Base64Binary(allow_none=True) spinCount = Integer(allow_none=True) content = Bool(allow_none=True) objects = Bool(allow_none=True) __attrs__ = ("content", "objects", "password", "hashValue", "spinCount", "saltValue", "algorithmName") def __init__(self, content=None, objects=None, hashValue=None, spinCount=None, saltValue=None, algorithmName=None, password=None, ): self.content = content self.objects = objects self.hashValue = hashValue self.spinCount = spinCount self.saltValue = saltValue self.algorithmName = algorithmName if password is not None: self.password = password
class IconSet(RuleType): tagname = "iconSet" iconSet = NoneSet(values=(['3Arrows', '3ArrowsGray', '3Flags', '3TrafficLights1', '3TrafficLights2', '3Signs', '3Symbols', '3Symbols2', '4Arrows', '4ArrowsGray', '4RedToBlack', '4Rating', '4TrafficLights', '5Arrows', '5ArrowsGray', '5Rating', '5Quarters'])) showValue = Bool(allow_none=True) percent = Bool(allow_none=True) reverse = Bool(allow_none=True) __elements__ = ("cfvo",) def __init__(self, iconSet=None, showValue=None, percent=None, reverse=None, cfvo=None, ): self.iconSet = iconSet self.showValue = showValue self.percent = percent self.reverse = reverse self.cfvo = cfvo
class RowDimension(Dimension): """Information about the display properties of a row.""" __fields__ = Dimension.__fields__ + ('ht', 'customFormat', 'customHeight', 's', 'thickBot', 'thickTop') r = Alias('index') s = Alias('style_id') ht = Float(allow_none=True) height = Alias('ht') thickBot = Bool() thickTop = Bool() def __init__( self, worksheet, index=0, ht=None, customHeight=None, # do not write s=None, customFormat=None, # do not write hidden=False, outlineLevel=0, outline_level=None, collapsed=False, visible=None, height=None, r=None, spans=None, thickBot=None, thickTop=None, **kw): if r is not None: index = r if height is not None: ht = height self.ht = ht if visible is not None: hidden = not visible if outline_level is not None: outlineLevel = outlineLevel self.thickBot = thickBot self.thickTop = thickTop super(RowDimension, self).__init__(index, hidden, outlineLevel, collapsed, worksheet, style=s) @property def customFormat(self): """Always true if there is a style for the row""" return self.has_style @property def customHeight(self): """Always true if there is a height for the row""" return self.ht is not None
class PageSetupProperties(Serialisable): tagname = "pageSetUpPr" autoPageBreaks = Bool(allow_none=True) fitToPage = Bool(allow_none=True) def __init__(self, autoPageBreaks=None, fitToPage=None): self.autoPageBreaks = autoPageBreaks self.fitToPage = fitToPage
class PivotHierarchy(Serialisable): tagname = "pivotHierarchy" outline = Bool() multipleItemSelectionAllowed = Bool() subtotalTop = Bool() showInFieldList = Bool() dragToRow = Bool() dragToCol = Bool() dragToPage = Bool() dragToData = Bool() dragOff = Bool() includeNewItemsInFilter = Bool() caption = String(allow_none=True) mps = NestedSequence(expected_type=MemberProperty, count=True) members = Typed(expected_type=MemberList, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ( 'mps', 'members', ) def __init__( self, outline=None, multipleItemSelectionAllowed=None, subtotalTop=None, showInFieldList=None, dragToRow=None, dragToCol=None, dragToPage=None, dragToData=None, dragOff=None, includeNewItemsInFilter=None, caption=None, mps=(), members=None, extLst=None, ): self.outline = outline self.multipleItemSelectionAllowed = multipleItemSelectionAllowed self.subtotalTop = subtotalTop self.showInFieldList = showInFieldList self.dragToRow = dragToRow self.dragToCol = dragToCol self.dragToPage = dragToPage self.dragToData = dragToData self.dragOff = dragOff self.includeNewItemsInFilter = includeNewItemsInFilter self.caption = caption self.mps = mps self.members = members self.extLst = extLst
class Protection(Serialisable): """Protection options for use in styles.""" tagname = "protection" locked = Bool() hidden = Bool() def __init__(self, locked=True, hidden=False): self.locked = locked self.hidden = hidden
class AnchorClientData(Serialisable): fLocksWithSheet = Bool(allow_none=True) fPrintsWithSheet = Bool(allow_none=True) def __init__( self, fLocksWithSheet=None, fPrintsWithSheet=None, ): self.fLocksWithSheet = fLocksWithSheet self.fPrintsWithSheet = fPrintsWithSheet
class BookView(Serialisable): tagname = "workbookView" visibility = NoneSet(values=(['visible', 'hidden', 'veryHidden'])) minimized = Bool(allow_none=True) showHorizontalScroll = Bool(allow_none=True) showVerticalScroll = Bool(allow_none=True) showSheetTabs = Bool(allow_none=True) xWindow = Integer(allow_none=True) yWindow = Integer(allow_none=True) windowWidth = Integer(allow_none=True) windowHeight = Integer(allow_none=True) tabRatio = Integer(allow_none=True) firstSheet = Integer(allow_none=True) activeTab = Integer(allow_none=True) autoFilterDateGrouping = Bool(allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = () def __init__( self, visibility=None, minimized=None, showHorizontalScroll=None, showVerticalScroll=None, showSheetTabs=None, xWindow=None, yWindow=None, windowWidth=None, windowHeight=None, tabRatio=None, firstSheet=None, activeTab=None, autoFilterDateGrouping=None, extLst=None, ): self.visibility = visibility self.minimized = minimized self.showHorizontalScroll = showHorizontalScroll self.showVerticalScroll = showVerticalScroll self.showSheetTabs = showSheetTabs self.xWindow = xWindow self.yWindow = yWindow self.windowWidth = windowWidth self.windowHeight = windowHeight self.tabRatio = tabRatio self.firstSheet = firstSheet self.activeTab = activeTab self.autoFilterDateGrouping = autoFilterDateGrouping
class FilterColumn(Serialisable): tagname = "filterColumn" colId = Integer() col_id = Alias('colId') hiddenButton = Bool(allow_none=True) showButton = Bool(allow_none=True) # some elements are choice filters = Typed(expected_type=Filters, allow_none=True) top10 = Typed(expected_type=Top10, allow_none=True) customFilters = Typed(expected_type=CustomFilters, allow_none=True) dynamicFilter = Typed(expected_type=DynamicFilter, allow_none=True) colorFilter = Typed(expected_type=ColorFilter, allow_none=True) iconFilter = Typed(expected_type=IconFilter, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('filters', 'top10', 'customFilters', 'dynamicFilter', 'colorFilter', 'iconFilter') def __init__(self, colId=None, hiddenButton=None, showButton=None, filters=None, top10=None, customFilters=None, dynamicFilter=None, colorFilter=None, iconFilter=None, extLst=None, blank=None, vals=None, ): self.colId = colId self.hiddenButton = hiddenButton self.showButton = showButton if filters is None: filters = Filters() self.filters = filters self.top10 = top10 self.customFilters = customFilters self.dynamicFilter = dynamicFilter self.colorFilter = colorFilter self.iconFilter = iconFilter if blank is not None: self.filters.blank = blank if vals is not None: self.filters.filter = vals
class ObjectAnchor(Serialisable): moveWithCells = Bool(allow_none=True) sizeWithCells = Bool(allow_none=True) #z-order = Integer(allow_none=True) needs alias #from #to defs from xdr def __init__(self, moveWithCells=None, sizeWithCells=None, #z-order=None, ): self.moveWithCells = moveWithCells self.sizeWithCells = sizeWithCells
class GradientFillProperties(Serialisable): tagname = "gradFill" flip = NoneSet(values=(['x', 'y', 'xy'])) rotWithShape = Bool(allow_none=True) gsLst = Typed(expected_type=GradientStopList, allow_none=True) stop_list = Alias("gsLst") lin = Typed(expected_type=LinearShadeProperties, allow_none=True) linear = Alias("lin") path = Typed(expected_type=PathShadeProperties, allow_none=True) tileRect = Typed(expected_type=RelativeRect, allow_none=True) __elements__ = ('gsLst', 'lin', 'path', 'tileRect') def __init__( self, flip=None, rotWithShape=None, gsLst=None, lin=None, path=None, tileRect=None, ): self.flip = flip self.rotWithShape = rotWithShape self.gsLst = gsLst self.lin = lin self.path = path self.tileRect = tileRect
class OLAPSet(Serialisable): tagname = "set" count = Integer() maxRank = Integer() setDefinition = String() sortType = NoneSet(values=(['ascending', 'descending', 'ascendingAlpha', 'descendingAlpha', 'ascendingNatural', 'descendingNatural'])) queryFailed = Bool() tpls = Typed(expected_type=TupleList, allow_none=True) sortByTuple = Typed(expected_type=TupleList, allow_none=True) __elements__ = ('tpls', 'sortByTuple') def __init__(self, count=None, maxRank=None, setDefinition=None, sortType=None, queryFailed=None, tpls=None, sortByTuple=None, ): self.count = count self.maxRank = maxRank self.setDefinition = setDefinition self.sortType = sortType self.queryFailed = queryFailed self.tpls = tpls self.sortByTuple = sortByTuple
class CustomChartsheetView(Serialisable): tagname = "customSheetView" guid = Guid() scale = Integer() state = Set(values=(['visible', 'hidden', 'veryHidden'])) zoomToFit = Bool(allow_none=True) pageMargins = Typed(expected_type=PageMargins, allow_none=True) pageSetup = Typed(expected_type=PrintPageSetup, allow_none=True) headerFooter = Typed(expected_type=HeaderFooter, allow_none=True) __elements__ = ('pageMargins', 'pageSetup', 'headerFooter') def __init__(self, guid=None, scale=None, state='visible', zoomToFit=None, pageMargins=None, pageSetup=None, headerFooter=None, ): self.guid = guid self.scale = scale self.state = state self.zoomToFit = zoomToFit self.pageMargins = pageMargins self.pageSetup = pageSetup self.headerFooter = headerFooter
class FileSharing(Serialisable): tagname = "fileSharing" readOnlyRecommended = Bool(allow_none=True) userName = String(allow_none=True) reservationPassword = HexBinary(allow_none=True) algorithmName = String(allow_none=True) hashValue = HexBinary(allow_none=True) saltValue = HexBinary(allow_none=True) spinCount = Integer(allow_none=True) def __init__( self, readOnlyRecommended=None, userName=None, reservationPassword=None, algorithmName=None, hashValue=None, saltValue=None, spinCount=None, ): self.readOnlyRecommended = readOnlyRecommended self.userName = userName self.reservationPassword = reservationPassword self.algorithmName = algorithmName self.hashValue = hashValue self.saltValue = saltValue self.spinCount = spinCount
class SortCondition(Serialisable): tagname = "sortCondition" descending = Bool(allow_none=True) sortBy = NoneSet(values=(['value', 'cellColor', 'fontColor', 'icon'])) ref = CellRange() customList = String(allow_none=True) dxfId = Integer(allow_none=True) iconSet = NoneSet(values=(['3Arrows', '3ArrowsGray', '3Flags', '3TrafficLights1', '3TrafficLights2', '3Signs', '3Symbols', '3Symbols2', '4Arrows', '4ArrowsGray', '4RedToBlack', '4Rating', '4TrafficLights', '5Arrows', '5ArrowsGray', '5Rating', '5Quarters'])) iconId = Integer(allow_none=True) def __init__(self, ref=None, descending=None, sortBy=None, customList=None, dxfId=None, iconSet=None, iconId=None, ): self.descending = descending self.sortBy = sortBy self.ref = ref self.customList = customList self.dxfId = dxfId self.iconSet = iconSet self.iconId = iconId
class CalculatedMember(Serialisable): tagname = "calculatedMember" name = String() mdx = String() memberName = String() hierarchy = String() parent = String() solveOrder = Integer() set = Bool() extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('extLst',) def __init__(self, name=None, mdx=None, memberName=None, hierarchy=None, parent=None, solveOrder=None, set=None, extLst=None, ): self.name = name self.mdx = mdx self.memberName = memberName self.hierarchy = hierarchy self.parent = parent self.solveOrder = solveOrder self.set = set self.extLst = extLst
class ConditionalFormatting(Serialisable): tagname = "conditionalFormatting" sqref = Convertible(expected_type=MultiCellRange) cells = Alias("sqref") pivot = Bool(allow_none=True) cfRule = Sequence(expected_type=Rule) rules = Alias("cfRule") def __init__(self, sqref=(), pivot=None, cfRule=(), extLst=None): self.sqref = sqref self.pivot = pivot self.cfRule = cfRule def __eq__(self, other): if not isinstance(other, self.__class__): return False return self.sqref == other.sqref def __hash__(self): return hash(str(self.sqref)) def __repr__(self): return "<{cls} {cells}>".format(cls=self.__class__.__name__, cells=self.sqref) def __contains__(self, coord): """ Check whether a certain cell is affected by the formatting """ return coord in self.sqref
class WebPublishItem(Serialisable): tagname = "webPublishItem" id = Integer() divId = String() sourceType = Set(values=([ 'sheet', 'printArea', 'autoFilter', 'range', 'chart', 'pivotTable', 'query', 'label' ])) sourceRef = String() sourceObject = String(allow_none=True) destinationFile = String() title = String(allow_none=True) autoRepublish = Bool(allow_none=True) def __init__( self, id=None, divId=None, sourceType=None, sourceRef=None, sourceObject=None, destinationFile=None, title=None, autoRepublish=None, ): self.id = id self.divId = divId self.sourceType = sourceType self.sourceRef = sourceRef self.sourceObject = sourceObject self.destinationFile = destinationFile self.title = title self.autoRepublish = autoRepublish
class WebPublishObject(Serialisable): tagname = "webPublishingObject" id = Integer() divId = String() sourceObject = String(allow_none=True) destinationFile = String() title = String(allow_none=True) autoRepublish = Bool(allow_none=True) def __init__( self, id=None, divId=None, sourceObject=None, destinationFile=None, title=None, autoRepublish=None, ): self.id = id self.divId = divId self.sourceObject = sourceObject self.destinationFile = destinationFile self.title = title self.autoRepublish = autoRepublish
class BlipFillProperties(Serialisable): tagname = "blipFill" dpi = Integer(allow_none=True) rotWithShape = Bool(allow_none=True) blip = Typed(expected_type=Blip, allow_none=True) srcRect = Typed(expected_type=RelativeRect, allow_none=True) tile = Typed(expected_type=TileInfoProperties, allow_none=True) stretch = Typed(expected_type=StretchInfoProperties, allow_none=True) __elements__ = ("blip", "srcRect", "tile", "stretch") def __init__( self, dpi=None, rotWithShape=None, blip=None, tile=None, stretch=StretchInfoProperties(), srcRect=None, ): self.dpi = dpi self.rotWithShape = rotWithShape self.blip = blip self.tile = tile self.stretch = stretch self.srcRect = srcRect
class NumFmt(Serialisable): formatCode = String() sourceLinked = Bool() def __init__(self, formatCode=None, sourceLinked=False): self.formatCode = formatCode self.sourceLinked = sourceLinked
class Color(Serialisable): """Named colors for use in styles.""" tagname = "color" rgb = RGB() indexed = Integer() auto = Bool() theme = Integer() tint = MinMax(min=-1, max=1, expected_type=float) type = String() def __init__(self, rgb=BLACK, indexed=None, auto=None, theme=None, tint=0.0, index=None, type='rgb'): if index is not None: indexed = index if indexed is not None: self.type = 'indexed' self.indexed = indexed elif theme is not None: self.type = 'theme' self.theme = theme elif auto is not None: self.type = 'auto' self.auto = auto else: self.rgb = rgb self.type = 'rgb' self.tint = tint @property def value(self): return getattr(self, self.type) @value.setter def value(self, value): setattr(self, self.type, value) def __iter__(self): attrs = [(self.type, self.value)] if self.tint != 0: attrs.append(('tint', self.tint)) for k, v in attrs: yield k, safe_string(v) @property def index(self): # legacy return self.value def __add__(self, other): """ Adding colours is undefined behaviour best do nothing """ if not isinstance(other, Color): return super(Color, self).__add__(other) return self
class Top10(Serialisable): tagname = "top10" top = Bool(allow_none=True) percent = Bool(allow_none=True) val = Float() filterVal = Float(allow_none=True) def __init__(self, top=None, percent=None, val=None, filterVal=None, ): self.top = top self.percent = percent self.val = val self.filterVal = filterVal
class Dimension(Strict, StyleableObject): """Information about the display properties of a row or column.""" __fields__ = ( 'hidden', 'outlineLevel', 'collapsed', ) index = Integer() hidden = Bool() outlineLevel = Integer(allow_none=True) outline_level = Alias('outlineLevel') collapsed = Bool() style = Alias('style_id') def __init__(self, index, hidden, outlineLevel, collapsed, worksheet, visible=True, style=None): super(Dimension, self).__init__(sheet=worksheet, style_array=style) self.index = index self.hidden = hidden self.outlineLevel = outlineLevel self.collapsed = collapsed def __iter__(self): for key in self.__fields__: value = getattr(self, key, None) if value: yield key, safe_string(value) def __copy__(self): cp = self.__new__(self.__class__) attrib = self.__dict__ attrib['worksheet'] = self.parent cp.__init__(**attrib) cp._style = copy(self._style) return cp