Exemplo n.º 1
0
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
Exemplo n.º 2
0
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__
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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 _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__()
Exemplo n.º 6
0
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__
Exemplo n.º 7
0
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
Exemplo n.º 8
0
class TableStyleList(Serialisable):

    tagname = "tableStyles"

    defaultTableStyle = String(allow_none=True)
    defaultPivotStyle = String(allow_none=True)
    tableStyle = Sequence(expected_type=TableStyle, allow_none=True)

    __elements__ = ('tableStyle', )
    __attrs__ = ("count", "defaultTableStyle", "defaultPivotStyle")

    def __init__(
            self,
            count=None,
            defaultTableStyle="TableStyleMedium9",
            defaultPivotStyle="PivotStyleLight16",
            tableStyle=(),
    ):
        self.defaultTableStyle = defaultTableStyle
        self.defaultPivotStyle = defaultPivotStyle
        self.tableStyle = tableStyle

    @property
    def count(self):
        return len(self.tableStyle)
Exemplo n.º 9
0
class Scenario(Serialisable):

    tagname = "scenario"

    inputCells = Sequence(expected_type=InputCells)
    name = String()
    locked = Bool(allow_none=True)
    hidden = Bool(allow_none=True)
    user = String(allow_none=True)
    comment = String(allow_none=True)

    __elements__ = ('inputCells', )
    __attrs__ = ('name', 'locked', 'hidden', 'user', 'comment', 'count')

    def __init__(
        self,
        inputCells=(),
        name=None,
        locked=False,
        hidden=False,
        count=None,
        user=None,
        comment=None,
    ):
        self.inputCells = inputCells
        self.name = name
        self.locked = locked
        self.hidden = hidden
        self.user = user
        self.comment = comment

    @property
    def count(self):
        return len(self.inputCells)
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
class Legend(Serialisable):

    tagname = "legend"

    legendPos = NestedSet(values=(['b', 'tr', 'l', 'r', 't']))
    position = Alias('legendPos')
    legendEntry = Sequence(expected_type=LegendEntry)
    layout = Typed(expected_type=Layout, allow_none=True)
    overlay = NestedBool(allow_none=True)
    spPr = Typed(expected_type=GraphicalProperties, allow_none=True)
    graphicalProperties = Alias('spPr')
    txPr = Typed(expected_type=RichText, allow_none=True)
    textProperties = Alias('txPr')
    extLst = Typed(expected_type=ExtensionList, allow_none=True)

    __elements__ = ('legendPos', 'legendEntry', 'layout', 'overlay', 'spPr', 'txPr',)

    def __init__(self,
                 legendPos="r",
                 legendEntry=(),
                 layout=None,
                 overlay=None,
                 spPr=None,
                 txPr=None,
                 extLst=None,
                ):
        self.legendPos = legendPos
        self.legendEntry = legendEntry
        self.layout = layout
        self.overlay = overlay
        self.spPr = spPr
        self.txPr = txPr
Exemplo n.º 12
0
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
Exemplo n.º 13
0
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
Exemplo n.º 14
0
class ScenarioList(Serialisable):

    tagname = "scenarios"

    scenario = Sequence(expected_type=Scenario)
    current = Integer(allow_none=True)
    show = Integer(allow_none=True)
    sqref = Convertible(expected_type=MultiCellRange, allow_none=True)

    __elements__ = ('scenario', )

    def __init__(
            self,
            scenario=(),
            current=None,
            show=None,
            sqref=None,
    ):
        self.scenario = scenario
        self.current = current
        self.show = show
        self.sqref = sqref

    def append(self, scenario):
        s = self.scenario
        s.append(scenario)
        self.scenario = s

    def __bool__(self):
        return bool(self.scenario)

    __nonzero__ = __bool__
Exemplo n.º 15
0
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%s" % len(values)
        self.hyperlink = values
Exemplo n.º 16
0
class GeomGuideList(Serialisable):

    gd = Sequence(expected_type=GeomGuide, allow_none=True)

    def __init__(
        self,
        gd=None,
    ):
        self.gd = gd
Exemplo n.º 17
0
class DashStopList(Serialisable):

    ds = Sequence(expected_type=DashStop, allow_none=True)

    def __init__(
        self,
        ds=None,
    ):
        self.ds = ds
Exemplo n.º 18
0
class ExtensionList(Serialisable):

    ext = Sequence(expected_type=Extension)

    def __init__(
            self,
            ext=(),
    ):
        self.ext = ext
Exemplo n.º 19
0
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)
Exemplo n.º 20
0
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)
Exemplo n.º 21
0
class ExternalSheetDataSet(Serialisable):

    sheetData = Sequence(expected_type=ExternalSheetData, )

    __elements__ = ('sheetData', )

    def __init__(
        self,
        sheetData=None,
    ):
        self.sheetData = sheetData
Exemplo n.º 22
0
class MRUColorList(Serialisable):

    color = Sequence(expected_type=Color, )

    __elements__ = ('color', )

    def __init__(
        self,
        color=None,
    ):
        self.color = color
Exemplo n.º 23
0
class IndexedColorList(Serialisable):

    rgbColor = Sequence(expected_type=RgbColor, )

    __elements__ = ('rgbColor', )

    def __init__(
            self,
            rgbColor=(),
    ):
        self.rgbColor = rgbColor
Exemplo n.º 24
0
class Controls(Serialisable):

    tagname = "controls"

    control = Sequence(expected_type=Control)

    __elements__ = ('control',)

    def __init__(self,
                 control=(),
                ):
        self.control = control
Exemplo n.º 25
0
class CellWatches(Serialisable):

    tagname = "cellWatches"

    cellWatch = Sequence(expected_type=CellWatch)

    __elements__ = ('cellWatch',)

    def __init__(self,
                 cellWatch=(),
                ):
        self.cellWatch = cellWatch
Exemplo n.º 26
0
class AuthorList(Serialisable):

    tagname = "authors"

    author = Sequence(expected_type=unicode)
    authors = Alias("author")

    def __init__(
            self,
            author=(),
    ):
        self.author = author
Exemplo n.º 27
0
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)
Exemplo n.º 28
0
class CustomProperties(Serialisable):

    tagname = "customProperties"

    customPr = Sequence(expected_type=CustomProperty)

    __elements__ = ('customPr', )

    def __init__(
            self,
            customPr=(),
    ):
        self.customPr = customPr
Exemplo n.º 29
0
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)
Exemplo n.º 30
0
class SmartTags(Serialisable):

    tagname = "smartTags"

    cellSmartTags = Sequence(expected_type=CellSmartTags)

    __elements__ = ('cellSmartTags', )

    def __init__(
            self,
            cellSmartTags=(),
    ):
        self.cellSmartTags = cellSmartTags