class Text(Serialisable): tagname = "s" tpls = Sequence(expected_type=TupleList) x = Sequence(expected_type=Index) v = String() 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 RichText(Serialisable): """ From the specification: 21.2.2.216 This element specifies text formatting. The lstStyle element is not supported. """ tagname = "rich" bodyPr = Typed(expected_type=RichTextProperties) properties = Alias("bodyPr") lstStyle = Typed(expected_type=ListStyle, allow_none=True) p = Sequence(expected_type=Paragraph) paragraphs = Alias('p') __elements__ = ("bodyPr", "lstStyle", "p") def __init__(self, bodyPr=None, lstStyle=None, p=None, ): if bodyPr is None: bodyPr = RichTextProperties() self.bodyPr = bodyPr self.lstStyle = lstStyle if p is None: p = [Paragraph()] self.p = p
class ScatterChart(ChartBase): tagname = "scatterChart" scatterStyle = NestedNoneSet(values=(['line', 'lineMarker', 'marker', 'smooth', 'smoothMarker'])) varyColors = NestedBool(allow_none=True) ser = Sequence(expected_type=XYSeries, allow_none=True) dLbls = Typed(expected_type=DataLabelList, allow_none=True) dataLabels = Alias("dLbls") extLst = Typed(expected_type=ExtensionList, allow_none=True) x_axis = Typed(expected_type=NumericAxis) y_axis = Typed(expected_type=NumericAxis) _series_type = "scatter" __elements__ = ('scatterStyle', 'varyColors', 'ser', 'dLbls', 'axId',) def __init__(self, scatterStyle=None, varyColors=None, ser=(), dLbls=None, extLst=None, **kw ): self.scatterStyle = scatterStyle self.varyColors = varyColors self.ser = ser self.dLbls = dLbls self.x_axis = NumericAxis(axId=10, crossAx=20) self.y_axis = NumericAxis(axId=20, crossAx=10) super(ScatterChart, self).__init__(**kw)
class Paragraph(Serialisable): tagname = "p" namespace = DRAWING_NS # uses element group EG_TextRun pPr = Typed(expected_type=ParagraphProperties, allow_none=True) properties = Alias("pPr") endParaRPr = Typed(expected_type=CharacterProperties, allow_none=True) r = Sequence(expected_type=RegularTextRun) text = Alias('r') br = Typed(expected_type=LineBreak, allow_none=True) fld = Typed(expected_type=TextField, allow_none=True) __elements__ = ('pPr', 'r', 'br', 'fld', 'endParaRPr') def __init__( self, pPr=None, endParaRPr=None, r=None, br=None, fld=None, ): self.pPr = pPr self.endParaRPr = endParaRPr if r is None: r = [RegularTextRun()] self.r = r self.br = br self.fld = fld
class SortState(Serialisable): tagname = "sortState" columnSort = Bool(allow_none=True) caseSensitive = Bool(allow_none=True) sortMethod = NoneSet(values=(['stroke', 'pinYin'])) ref = CellRange() sortCondition = Sequence(expected_type=SortCondition, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('sortCondition', ) def __init__( self, columnSort=None, caseSensitive=None, sortMethod=None, ref=None, sortCondition=(), extLst=None, ): self.columnSort = columnSort self.caseSensitive = caseSensitive self.sortMethod = sortMethod self.ref = ref self.sortCondition = sortCondition def __bool__(self): return self.ref is not None __nonzero__ = __bool__
class Filters(Serialisable): tagname = "filters" blank = Bool(allow_none=True) calendarType = NoneSet(values=[ "gregorian", "gregorianUs", "gregorianMeFrench", "gregorianArabic", "hijri", "hebrew", "taiwan", "japan", "thai", "korea", "saka", "gregorianXlitEnglish", "gregorianXlitFrench" ]) filter = ValueSequence(expected_type=unicode) dateGroupItem = Sequence(expected_type=DateGroupItem, allow_none=True) __elements__ = ('filter', 'dateGroupItem') def __init__( self, blank=None, calendarType=None, filter=(), dateGroupItem=(), ): self.blank = blank self.calendarType = calendarType self.filter = filter self.dateGroupItem = dateGroupItem
class _BarChartBase(ChartBase): barDir = NestedSet(values=(['bar', 'col'])) type = Alias("barDir") grouping = NestedSet( values=(['percentStacked', 'clustered', 'standard', 'stacked'])) varyColors = NestedBool(nested=True, allow_none=True) ser = Sequence(expected_type=Series, allow_none=True) dLbls = Typed(expected_type=DataLabelList, allow_none=True) dataLabels = Alias("dLbls") __elements__ = ('barDir', 'grouping', 'varyColors', 'ser', 'dLbls') _series_type = "bar" def __init__(self, barDir="col", grouping="clustered", varyColors=None, ser=(), dLbls=None, **kw): self.barDir = barDir self.grouping = grouping self.varyColors = varyColors self.ser = ser self.dLbls = dLbls super(_BarChartBase, self).__init__(**kw)
class TablePartList(Serialisable): tagname = "tableParts" count = Integer(allow_none=True) tablePart = Sequence(expected_type=Related) __elements__ = ('tablePart',) __attrs__ = ('count',) def __init__(self, count=None, tablePart=(), ): self.tablePart = tablePart def append(self, part): self.tablePart.append(part) @property def count(self): return len(self.tablePart) def __bool__(self): return bool(self.tablePart) __nonzero__ = __bool__
class DataLabelList(_DataLabelBase): tagname = "dLbls" dLbl = Sequence(expected_type=DataLabel, allow_none=True) delete = NestedBool(allow_none=True) numFmt = _DataLabelBase.numFmt spPr = _DataLabelBase.spPr txPr = _DataLabelBase.txPr dLblPos = _DataLabelBase.dLblPos showLegendKey = _DataLabelBase.showLegendKey showVal = _DataLabelBase.showVal showCatName = _DataLabelBase.showCatName showSerName = _DataLabelBase.showSerName showPercent = _DataLabelBase.showPercent showBubbleSize = _DataLabelBase.showBubbleSize showLeaderLines = _DataLabelBase.showLeaderLines separator = _DataLabelBase.separator extLst = _DataLabelBase.extLst __elements__ = ( "delete", "dLbl", ) + _DataLabelBase.__elements__ def __init__(self, dLbl=(), delete=None, **kw): self.dLbl = dLbl self.delete = delete super(DataLabelList, self).__init__(**kw)
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 _AreaChartBase(ChartBase): grouping = NestedSet(values=(['percentStacked', 'standard', 'stacked'])) varyColors = NestedBool(nested=True, allow_none=True) ser = Sequence(expected_type=Series, allow_none=True) dLbls = Typed(expected_type=DataLabelList, allow_none=True) dataLabels = Alias("dLbls") dropLines = Typed(expected_type=ChartLines, allow_none=True) _series_type = "area" __elements__ = ('grouping', 'varyColors', 'ser', 'dLbls', 'dropLines') def __init__( self, grouping="standard", varyColors=None, ser=(), dLbls=None, dropLines=None, ): self.grouping = grouping self.varyColors = varyColors self.ser = ser self.dLbls = dLbls self.dropLines = dropLines super(_AreaChartBase, self).__init__()
class HyperlinkList(Serialisable): tagname = "hyperlinks" hyperlink = Sequence(expected_type=Hyperlink) def __init__(self, hyperlink=()): self.hyperlink = hyperlink def __bool__(self): return bool(self.hyperlink) __nonzero__ = __bool__ def __len__(self): return len(self.hyperlink) def append(self, value): values = self.hyperlink[:] values.append(value) if not value.id: value.id = "rId{0}".format(len(values)) self.hyperlink = values
class GeomGuideList(Serialisable): gd = Sequence(expected_type=GeomGuide, allow_none=True) def __init__( self, gd=None, ): self.gd = gd
class DashStopList(Serialisable): ds = Sequence(expected_type=DashStop, allow_none=True) def __init__( self, ds=None, ): self.ds = ds
class ExternalSheetDataSet(Serialisable): sheetData = Sequence(expected_type=ExternalSheetData, ) __elements__ = ('sheetData',) def __init__(self, sheetData=None, ): self.sheetData = sheetData
class AutoFilter(Serialisable): tagname = "autoFilter" ref = CellRange() filterColumn = Sequence(expected_type=FilterColumn, allow_none=True) sortState = Typed(expected_type=SortState, allow_none=True) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('filterColumn', 'sortState') def __init__( self, ref=None, filterColumn=(), sortState=None, extLst=None, ): self.ref = ref self.filterColumn = filterColumn self.sortState = sortState def __bool__(self): return self.ref is not None __nonzero__ = __bool__ def add_filter_column(self, col_id, vals, blank=False): """ Add row filter for specified column. :param col_id: Zero-origin column id. 0 means first column. :type col_id: int :param vals: Value list to show. :type vals: str[] :param blank: Show rows that have blank cell if True (default=``False``) :type blank: bool """ self.filterColumn.append( FilterColumn(colId=col_id, filters=Filters(blank=blank, filter=vals))) def add_sort_condition(self, ref, descending=False): """ Add sort condition for cpecified range of cells. :param ref: range of the cells (e.g. 'A2:A150') :type ref: string :param descending: Descending sort order (default=``False``) :type descending: bool """ cond = SortCondition(ref, descending) if self.sortState is None: self.sortState = SortState(ref=ref) self.sortState.sortCondition.append(cond)
class CellStyleList(Serialisable): tagname = "cellXfs" __attrs__ = ("count", ) count = Integer(allow_none=True) xf = Sequence(expected_type=CellStyle) alignment = Sequence(expected_type=Alignment) protection = Sequence(expected_type=Protection) __elements__ = ('xf', ) def __init__( self, count=None, xf=(), ): self.xf = xf @property def count(self): return len(self.xf) def __getitem__(self, idx): return self.xf[idx] def _to_array(self): """ Extract protection and alignments, convert to style array """ self.prots = IndexedList([Protection()]) self.alignments = IndexedList([Alignment()]) styles = [] # allow duplicates for xf in self.xf: style = xf.to_array() if xf.alignment is not None: style.alignmentId = self.alignments.add(xf.alignment) if xf.protection is not None: style.protectionId = self.prots.add(xf.protection) styles.append(style) return IndexedList(styles)
class AuthorList(Serialisable): tagname = "authors" author = Sequence(expected_type=unicode) authors = Alias("author") def __init__( self, author=(), ): self.author = author
class Level(Serialisable): tagname = "lvl" pt = Sequence(expected_type=StrVal) __elements__ = ('pt',) def __init__(self, pt=(), ): self.pt = pt
class GroupItems(Serialisable): tagname = "groupItems" m = Sequence(expected_type=Missing) n = Sequence(expected_type=Number) b = Sequence(expected_type=Boolean) e = Sequence(expected_type=Error) s = Sequence(expected_type=Text) d = Sequence(expected_type=DateTimeField, ) __elements__ = ('m', 'n', 'b', 'e', 's', 'd') __attrs__ = ("count", ) def __init__( self, count=None, m=(), n=(), b=(), e=(), s=(), d=(), ): self.m = m self.n = n self.b = b self.e = e self.s = s self.d = d @property def count(self): return len(self.m + self.n + self.b + self.e + self.s + self.d)
class ExternalRow(Serialisable): r = Integer() cell = Sequence(expected_type=ExternalCell) __elements__ = ('cell',) def __init__(self, r=(), cell=None, ): self.r = r self.cell = cell
class Text(Serialisable): tagname = "text" t = NestedText(allow_none=True, expected_type=unicode) plain = Alias("t") r = Sequence(expected_type=RichText, allow_none=True) formatted = Alias("r") rPh = Sequence(expected_type=PhoneticText, allow_none=True) phonetic = Alias("rPh") phoneticPr = Typed(expected_type=PhoneticProperties, allow_none=True) PhoneticProperties = Alias("phoneticPr") __elements__ = ('t', 'r', 'rPh', 'phoneticPr') def __init__( self, t=None, r=(), rPh=(), phoneticPr=None, ): self.t = t self.r = r self.rPh = rPh self.phoneticPr = phoneticPr @property def content(self): """ Text stripped of all formatting """ snippets = [] if self.plain is not None: snippets.append(self.plain) for block in self.formatted: if block.t is not None: snippets.append(block.t) return u"".join(snippets)
class PivotFormatList(Serialisable): tagname = "pivotFmts" pivotFmt = Sequence(expected_type=PivotFormat, allow_none=True) __elements__ = ('pivotFmt', ) def __init__( self, pivotFmt=(), ): self.pivotFmt = pivotFmt
class BandFormatList(Serialisable): tagname = "bandFmts" bandFmt = Sequence(expected_type=BandFormat, allow_none=True) __elements__ = ('bandFmt', ) def __init__( self, bandFmt=(), ): self.bandFmt = bandFmt
class CustomChartsheetViews(Serialisable): tagname = "customSheetViews" customSheetView = Sequence(expected_type=CustomChartsheetView, allow_none=True) __elements__ = ('customSheetView', ) def __init__( self, customSheetView=None, ): self.customSheetView = customSheetView
class SmartTagList(Serialisable): tagname = "smartTagTypes" smartTagType = Sequence(expected_type=SmartTag, allow_none=True) __elements__ = ('smartTagType', ) def __init__( self, smartTagType=(), ): self.smartTagType = smartTagType
class _SurfaceChartBase(ChartBase): wireframe = NestedBool(allow_none=True) ser = Sequence(expected_type=Series, allow_none=True) bandFmts = Typed(expected_type=BandFormatList, allow_none=True) _series_type = "surface" __elements__ = ('wireframe', 'ser', 'bandFmts') def __init__(self, wireframe=None, ser=(), bandFmts=None, **kw): self.wireframe = wireframe self.ser = ser self.bandFmts = bandFmts super(_SurfaceChartBase, self).__init__(**kw)
class WebPublishItems(Serialisable): tagname = "WebPublishItems" count = Integer(allow_none=True) webPublishItem = Sequence(expected_type=WebPublishItem, ) __elements__ = ('webPublishItem', ) def __init__( self, count=None, webPublishItem=None, ): self.count = len(webPublishItem) self.webPublishItem = webPublishItem
class FunctionGroupList(Serialisable): tagname = "functionGroups" builtInGroupCount = Integer(allow_none=True) functionGroup = Sequence(expected_type=FunctionGroup, allow_none=True) __elements__ = ('functionGroup', ) def __init__( self, builtInGroupCount=16, functionGroup=(), ): self.builtInGroupCount = builtInGroupCount self.functionGroup = functionGroup
class ChartsheetViewList(Serialisable): tagname = "sheetViews" sheetView = Sequence(expected_type=ChartsheetView, ) extLst = Typed(expected_type=ExtensionList, allow_none=True) __elements__ = ('sheetView', ) def __init__( self, sheetView=None, extLst=None, ): if sheetView is None: sheetView = [ChartsheetView()] self.sheetView = sheetView