Example #1
0
def test_merge_comments_vml(datadir):
    datadir.chdir()
    cw = ShapeWriter(create_comments())

    with open('control+comments.vml') as existing:
        content = fromstring(cw.write(fromstring(existing.read())))
    assert len(content.findall('{%s}shape' % vmlns)) == 5
    assert len(content.findall('{%s}shapetype' % vmlns)) == 2
Example #2
0
    def test_from_xml(self, DateAxis):
        from openpyxl25.chart.data_source import NumFmt

        src = """
        <dateAx>
          <axId val="20"/>
          <scaling>
            <orientation val="minMax"/>
          </scaling>
          <delete val="0"/>
          <axPos val="b"/>
          <numFmt formatCode="d-mmm" sourceLinked="1"/>
          <majorTickMark val="out"/>
          <minorTickMark val="none"/>
          <tickLblPos val="nextTo"/>
          <crossAx val="10"/>
          <crosses val="autoZero"/>
          <auto val="1"/>
          <lblOffset val="100"/>
          <baseTimeUnit val="months"/>
        </dateAx>
        """
        node = fromstring(src)
        axis = DateAxis.from_tree(node)
        assert axis == DateAxis(axId=20,
                                crossAx=10,
                                axPos="b",
                                delete=False,
                                numFmt=NumFmt("d-mmm", True),
                                majorTickMark="out",
                                crosses="autoZero",
                                tickLblPos="nextTo",
                                auto=True,
                                lblOffset=100,
                                baseTimeUnit="months")
Example #3
0
 def test_from_xml(self, Boolean):
     src = """
     <b />
     """
     node = fromstring(src)
     boolean = Boolean.from_tree(node)
     assert boolean == Boolean()
Example #4
0
 def test_from_xml(self, DateTimeField):
     src = """
     <d v="2016-03-24T00:00:00"/>
     """
     node = fromstring(src)
     record = DateTimeField.from_tree(node)
     assert record == DateTimeField(v=datetime(2016, 3, 24))
Example #5
0
 def test_from_xml(self, Text):
     src = """
     <s v="UCLA" />
     """
     node = fromstring(src)
     text = Text.from_tree(node)
     assert text == Text(v="UCLA")
Example #6
0
def test_read_fills():
    # Make sure we pass the right class

    from ..fills import Fill
    s = """
    <fills count="3" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
    <fill>
      <patternFill patternType="none" />
    </fill>
    <fill>
      <patternFill patternType="gray125" />
    </fill>
    <fill>
      <gradientFill type="path" left="0.5" right="0.5" top="0.5" bottom="0.5">
        <stop position="0">
          <color theme="0" tint="-5.0935392315439317E-2" />
        </stop>
        <stop position="1">
          <color theme="0" tint="-0.25098422193060094" />
        </stop>
      </gradientFill>
    </fill>
    </fills>
    """
    xml = fromstring(s)
    for node in xml:
        fill = Fill.from_tree(node)
Example #7
0
 def test_from_xml(self, InlineFont):
     src = """
     <RPrElt />
     """
     node = fromstring(src)
     font = InlineFont.from_tree(node)
     assert font == InlineFont()
Example #8
0
 def test_from_xml(self, TableStyleElement):
     src = """
     <tableStyleElement type="secondRowStripe" size="2" />
     """
     node = fromstring(src)
     table = TableStyleElement.from_tree(node)
     assert table == TableStyleElement(type="secondRowStripe", size=2)
Example #9
0
 def test_from_xml(self, PivotFormatList):
     src = """
     <pivotFmts />
     """
     node = fromstring(src)
     fmt = PivotFormatList.from_tree(node)
     assert fmt == PivotFormatList()
Example #10
0
    def test_from_tree(self):
        from openpyxl25.chart.series import Series, attribute_mapping

        src = """
        <ser>
          <idx val="0"/>
          <order val="0"/>
          <spPr>
              <a:ln xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                <a:prstDash val="solid" />
              </a:ln>
            </spPr>
          <val>
            <numRef>
              <f>Blatt1!$A$1:$A$12</f>
            </numRef>
          </val>
        </ser>
        """
        node = fromstring(src)
        ser = Series.from_tree(node)
        assert ser.idx == 0
        assert ser.order == 0
        assert ser.val.numRef.ref == 'Blatt1!$A$1:$A$12'

        ser.__elements__ = attribute_mapping['area']
        xml = tostring(ser.to_tree())
        diff = compare_xml(xml, src)
        assert diff is None, diff
Example #11
0
 def test_from_xml(self, PlotArea):
     src = """
     <plotArea />
     """
     node = fromstring(src)
     plot = PlotArea.from_tree(node)
     assert plot == PlotArea()
Example #12
0
 def test_from_xml(self, DataTable):
     src = """
     <dTable />
     """
     node = fromstring(src)
     table = DataTable.from_tree(node)
     assert table == DataTable()
Example #13
0
 def from_xml(self, TextAxis):
     src = """
     <catAx>
         <axId val="2065276984"/>
         <scaling>
           <orientation val="minMax"/>
         </scaling>
         <delete val="0"/>
         <axPos val="b"/>
         <majorTickMark val="out"/>
         <minorTickMark val="none"/>
         <tickLblPos val="nextTo"/>
         <crossAx val="2056619928"/>
         <crosses val="autoZero"/>
         <auto val="1"/>
         <lblAlgn val="ctr"/>
         <lblOffset val="100"/>
         <noMultiLvlLbl val="0"/>
     </catAx>
     """
     node = fromstring(src)
     axis = CatAx.from_tree(node)
     assert axis.scaling.orientation == "minMax"
     assert axis.auto is True
     assert axis.majorTickMark == "out"
     assert axis.minorTickMark is None
Example #14
0
 def test_from_xml(self, ChartLines):
     src = """
     <chartLines />
     """
     node = fromstring(src)
     axis = ChartLines.from_tree(node)
     assert axis == ChartLines()
Example #15
0
 def test_from_xml(self, DisplayUnitsLabelList):
     src = """
     <dispUnits />
     """
     node = fromstring(src)
     axis = DisplayUnitsLabelList.from_tree(node)
     assert axis == DisplayUnitsLabelList()
Example #16
0
 def test_from_xml(self, TableStyle):
     src = """
     <tableStyle name="medium" />
     """
     node = fromstring(src)
     table = TableStyle.from_tree(node)
     assert table == TableStyle(name="medium")
Example #17
0
 def test_from_xml(self, TableStyleList):
     src = """
     <tableStyles />
     """
     node = fromstring(src)
     table = TableStyleList.from_tree(node)
     assert table == TableStyleList()
Example #18
0
 def test_from_xml(self, ExternalData):
     src = """
     <externalData id="rId1"/>
     """
     node = fromstring(src)
     data = ExternalData.from_tree(node)
     assert data == ExternalData(id="rId1")
Example #19
0
 def test_from_xml(self, PhoneticProperties):
     src = """
    <phoneticPr fontId="0" type="noConversion"/>
     """
     node = fromstring(src)
     props = PhoneticProperties.from_tree(node)
     assert props == PhoneticProperties(fontId=0, type="noConversion")
Example #20
0
 def test_from_xml(self, Surface):
     src = """
     <surface />
     """
     node = fromstring(src)
     surface = Surface.from_tree(node)
     assert surface == Surface()
Example #21
0
 def test_from_xml(self, RichText):
     src = """
     <RElt />
     """
     node = fromstring(src)
     text = RichText.from_tree(node)
     assert text == RichText()
Example #22
0
 def test_from_xml(self, PrintSettings):
     src = """
     <printSettings />
     """
     node = fromstring(src)
     chartspace = PrintSettings.from_tree(node)
     assert chartspace == PrintSettings()
Example #23
0
 def test_from_xml(self, Number):
     src = """
     <n v="15" />
     """
     node = fromstring(src)
     number = Number.from_tree(node)
     assert number == Number(v=15)
Example #24
0
 def test_from_xml(self, PageMargins):
     src = """
     <pageMargins b="1.0" l="0.75" r="0.75" t="1.0" header="0.5" footer="0.5"/>
     """
     node = fromstring(src)
     pm = PageMargins.from_tree(node)
     assert pm == PageMargins()
Example #25
0
 def test_from_xml(self, Index):
     src = """
     <x v="1" />
     """
     node = fromstring(src)
     record = Index.from_tree(node)
     assert record == Index(v=1)
Example #26
0
 def test_from_xml(self, BandFormatList):
     src = """
     <bandFmts />
     """
     node = fromstring(src)
     fmt = BandFormatList.from_tree(node)
     assert fmt == BandFormatList()
Example #27
0
 def test_from_xml(self, Error):
     src = """
     <e v="error" />
     """
     node = fromstring(src)
     error = Error.from_tree(node)
     assert error == Error(v="error")
Example #28
0
 def test_from_xml(self, SurfaceChart3D):
     src = """
     <surface3DChart>
     <wireframe val="0"/>
     <ser>
       <idx val="0"/>
       <order val="0"/>
       <val>
         <numRef>
           <f>Blatt1!$A$1:$A$12</f>
         </numRef>
       </val>
     </ser>
     <ser>
       <idx val="1"/>
       <order val="1"/>
       <val>
         <numRef>
           <f>Blatt1!$B$1:$B$12</f>
         </numRef>
       </val>
     </ser>
     <bandFmts/>
     <axId val="2082935272"/>
     <axId val="2082938248"/>
     <axId val="2082941288"/>
     </surface3DChart>
     """
     node = fromstring(src)
     chart = SurfaceChart3D.from_tree(node)
     assert len(chart.ser) == 2
     assert chart.axId == [2082935272, 2082938248, 2082941288]
Example #29
0
 def test_from_xml(self, Missing):
     src = """
     <m />
     """
     node = fromstring(src)
     missing = Missing.from_tree(node)
     assert missing == Missing()
Example #30
0
 def test_from_xml(self, NumericAxis):
     src = """
     <valAx>
         <axId val="2056619928"/>
         <scaling>
             <logBase val="10" />
             <orientation val="minMax"/>
         </scaling>
         <delete val="0"/>
         <axPos val="l"/>
         <majorGridlines/>
         <numFmt formatCode="General" sourceLinked="1"/>
         <majorTickMark val="out"/>
         <minorTickMark val="none"/>
         <tickLblPos val="nextTo"/>
         <crossAx val="2065276984"/>
         <crosses val="autoZero"/>
         <crossBetween val="between"/>
     </valAx>
     """
     node = fromstring(src)
     axis = NumericAxis.from_tree(node)
     assert axis.delete is False
     assert axis.crossAx == 2065276984
     assert axis.crossBetween == "between"
     assert axis.scaling.logBase == 10