コード例 #1
0
ファイル: test_web.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, WebPublishObject):
     src = """
     <webPublishingObject destinationFile="www" divId="main" id="1" />
     """
     node = fromstring(src)
     obj = WebPublishObject.from_tree(node)
     assert obj == WebPublishObject(id=1,
                                    divId="main",
                                    destinationFile="www")
コード例 #2
0
ファイル: test_fills.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, Stop):
     src = """
     <stop position=".5">
           <color rgb="00999999"></color>
     </stop>
     """
     node = fromstring(src)
     stop = Stop.from_tree(node)
     assert stop == Stop('999999', .5)
コード例 #3
0
 def test_from_xml(self, StrData):
     src = """
     <strData>
        <ptCount val="4"></ptCount>
     </strData>
     """
     node = fromstring(src)
     data_source = StrData.from_tree(node)
     assert data_source == StrData(ptCount=4)
コード例 #4
0
 def test_from_xml(self, SeriesLabel):
     src = """
     <tx>
       <v>Label</v>
     </tx>
     """
     node = fromstring(src)
     label = SeriesLabel.from_tree(node)
     assert label == SeriesLabel(v="Label")
コード例 #5
0
 def test_from_xml(self, GradientStop):
     src = """
     <a:gs xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" pos="0">
       <a:prstClr val="blue"/>
     </a:gs>
     """
     node = fromstring(src)
     fill = GradientStop.from_tree(node)
     assert fill == GradientStop(pos=0, prstClr="blue")
コード例 #6
0
ファイル: test_trendline.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, Trendline):
     src = """
     <trendline>
       <trendlineType val="log" />
     </trendline>
     """
     node = fromstring(src)
     trendline = Trendline.from_tree(node)
     assert trendline == Trendline(trendlineType="log")
コード例 #7
0
 def test_from_xml(self, StrVal):
     src = """
     <pt idx="4">
       <v>else</v>
     </pt>
     """
     node = fromstring(src)
     val = StrVal.from_tree(node)
     assert val == StrVal(idx=4, v="else")
コード例 #8
0
 def test_read(self, HeaderFooterItem):
     xml = """
     <oddHeader>&amp;L&amp;"Lucida Grande,Standard"&amp;K000000&amp;12 Left top&amp;C&amp;"Lucida Grande,Standard"&amp;K000000Middle top&amp;R&amp;"Lucida Grande,Standard"&amp;K000000Right top</oddHeader>
     """
     node = fromstring(xml)
     hf = HeaderFooterItem.from_tree(node)
     assert hf.left.text == "Left top"
     assert hf.center.text == "Middle top"
     assert hf.right.text == "Right top"
コード例 #9
0
 def test_from_xml(self, Format, PivotArea):
     src = """
     <format action="blank">
       <pivotArea dataOnly="0" labelOnly="1" outline="0" fieldPosition="0" />
     </format>
     """
     node = fromstring(src)
     fmt = Format.from_tree(node)
     area = PivotArea(outline=False, fieldPosition=False, labelOnly=True, dataOnly=False)
     assert fmt == Format(action="blank", pivotArea=area)
コード例 #10
0
 def test_from_xml(self, ChartFormat, PivotArea):
     src = """
     <chartFormat chart="0" format="12" series="1">
       <pivotArea type="normal" outline="1" dataOnly="1"/>
     </chartFormat>
     """
     node = fromstring(src)
     fmt = ChartFormat.from_tree(node)
     area = PivotArea()
     assert fmt == ChartFormat(chart=0, format=12, series=1, pivotArea=area)
コード例 #11
0
def test_read_workbook_code_name(datadir, WorkbookPackage):
    datadir.chdir()

    with open("workbook_russian_code_name.xml", "rb") as src:
        xml = src.read()

    node = fromstring(xml)
    parser = WorkbookPackage.from_tree(node)

    assert parser.properties.codeName == u'\u042d\u0442\u0430\u041a\u043d\u0438\u0433\u0430'
コード例 #12
0
 def test_from_xml(self, BubbleChart):
     src = """
     <bubbleChart>
       <axId val="10" />
       <axId val="20" />
     </bubbleChart>
     """
     node = fromstring(src)
     bubble_chart = BubbleChart.from_tree(node)
     assert bubble_chart.axId == [10, 20]
コード例 #13
0
ファイル: test_marker.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, Marker):
     src = """
     <marker>
         <symbol val="square"/>
         <size val="5"/>
     </marker>
     """
     node = fromstring(src)
     marker = Marker.from_tree(node)
     assert marker == Marker(symbol="square", size=5)
コード例 #14
0
 def test_from_xml(self, LineProperties):
     src = """
     <ln w="38100" cmpd="sng">
       <prstDash val="solid"/>
       <miter lim="5" />
     </ln>
     """
     node = fromstring(src)
     line = LineProperties.from_tree(node)
     assert line == LineProperties(w=38100, cmpd="sng", miter=5)
コード例 #15
0
    def test_read_chart(self, SpreadsheetDrawing, datadir):
        datadir.chdir()
        with open("spreadsheet_drawing_with_chart.xml") as src:
            xml = src.read()
        node = fromstring(xml)

        drawing = SpreadsheetDrawing.from_tree(node)
        chart_rels = drawing._chart_rels
        assert len(chart_rels) == 1
        assert chart_rels[0].anchor is not None
コード例 #16
0
ファイル: test_chartspace.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, ChartContainer):
     src = """
     <chart>
       <plotArea></plotArea>
       <dispBlanksAs val="gap"></dispBlanksAs>
     </chart>
     """
     node = fromstring(src)
     container = ChartContainer.from_tree(node)
     assert container == ChartContainer()
コード例 #17
0
 def test_read_formula(self, DataValidation):
     xml = """
     <dataValidation xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" allowBlank="0" showErrorMessage="1" showInputMessage="1" sqref="A1" type="list">
       <formula1>&quot;Dog,Cat,Fish&quot;</formula1>
     </dataValidation>
     """
     xml = fromstring(xml)
     dv = DataValidation.from_tree(xml)
     assert dv.type == "list"
     assert dv.formula1 == '"Dog,Cat,Fish"'
コード例 #18
0
 def test_from_xml(self, HeaderFooter):
     src = """
      <headerFooter>
        <oddHeader>&amp;L&amp;"Lucida Grande,Standard"&amp;K000000Left top&amp;C&amp;"Lucida Grande,Standard"&amp;K000000Middle top&amp;R&amp;"Lucida Grande,Standard"&amp;K000000Right top</oddHeader>
        <oddFooter>&amp;L&amp;"Lucida Grande,Standard"&amp;K000000Left footer&amp;C&amp;"Lucida Grande,Standard"&amp;K000000Middle Footer&amp;R&amp;"Lucida Grande,Standard"&amp;K000000Right Footer</oddFooter>
     </headerFooter>
     """
     node = fromstring(src)
     hf = HeaderFooter.from_tree(node)
     assert hf.oddHeader.left.text == "Left top"
コード例 #19
0
 def test_from_xml(self, StockChart):
     src = """
     <stockChart>
       <axId val="10"></axId>
       <axId val="100"></axId>
     </stockChart>
     """
     node = fromstring(src)
     chart = StockChart.from_tree(node)
     assert chart.axId == [10, 100]
コード例 #20
0
 def test_cleanup(self, DefinedNameList, datadir):
     datadir.chdir()
     with open("broken_print_titles.xml") as src:
         xml = src.read()
     node = fromstring(xml)
     dl = DefinedNameList.from_tree(node)
     assert len(dl) == 5
     dl._cleanup()
     assert len(dl) == 2
     assert dl.get("_xlnm._FilterDatabase", 0) is None
コード例 #21
0
ファイル: test_chartspace.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, PivotSource):
     src = """
     <pivotSource>
       <name>pivot source</name>
       <fmtId val="1" />
     </pivotSource>
     """
     node = fromstring(src)
     src = PivotSource.from_tree(node)
     assert src == PivotSource(name="pivot source", fmtId=1)
コード例 #22
0
ファイル: test_cache.py プロジェクト: sciris/openpyexcel
 def test_from_xml(self, CacheSource, WorksheetSource):
     src = """
     <cacheSource type="worksheet">
       <worksheetSource name="mydata"/>
     </cacheSource>
     """
     node = fromstring(src)
     source = CacheSource.from_tree(node)
     ws = WorksheetSource(name="mydata")
     assert source == CacheSource(type="worksheet", worksheetSource=ws)
コード例 #23
0
ファイル: external.py プロジェクト: BatataWada1/NOP-commerce
def read_external_link(archive, book_path):
    src = archive.read(book_path)
    node = fromstring(src)
    book = ExternalLink.from_tree(node)

    link_path = get_rels_path(book_path)
    deps = get_dependents(archive, link_path)
    book.file_link = deps.Relationship[0]

    return book
コード例 #24
0
 def test_from_xml(self, _NamedCellStyle):
     src = """
     <cellStyle name="Followed Hyperlink" xfId="10" builtinId="9" hidden="1"/>
     """
     node = fromstring(src)
     named_style = _NamedCellStyle.from_tree(node)
     assert named_style == _NamedCellStyle(name="Followed Hyperlink",
                                           xfId=10,
                                           builtinId=9,
                                           hidden=True)
コード例 #25
0
    def test_read_blip(self, SpreadsheetDrawing, datadir, path):
        datadir.chdir()
        with open(path, "rb") as src:
            xml = src.read()
        node = fromstring(xml)

        drawing = SpreadsheetDrawing.from_tree(node)
        blip_rels = drawing._blip_rels
        assert len(blip_rels) == 1
        assert blip_rels[0].anchor is not None
コード例 #26
0
    def test_read_comments(self, datadir):
        from ..comment_sheet import CommentSheet

        datadir.chdir()
        with open("comments1.xml") as src:
            node = fromstring(src.read())

        comments = CommentSheet.from_tree(node)
        assert comments.authors.author == ['author2', 'author', 'author3']
        assert len(comments.commentList) == 3
コード例 #27
0
 def test_from_xml(self, Hyperlink):
     src = """
     <hyperlink xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
         display="http://test.com" r:id="rId1" ref="A1"/>
     """
     node = fromstring(src)
     hyperlink = Hyperlink.from_tree(node)
     assert hyperlink == Hyperlink(display="http://test.com",
                                   ref="A1",
                                   id="rId1")
コード例 #28
0
def test_vba_comments(datadir, write_worksheet):
    datadir.chdir()
    fname = 'vba+comments.xlsm'
    wb = load_workbook(fname, keep_vba=True)
    ws = wb['Form Controls']
    sheet = fromstring(write_worksheet(ws))
    els = sheet.findall('{%s}legacyDrawing' % SHEET_MAIN_NS)
    assert len(
        els) == 1, "Wrong number of legacyDrawing elements %d" % len(els)
    assert els[0].get('{%s}id' % REL_NS) == 'anysvml'
コード例 #29
0
 def test_from_xml(self, NonVisualGraphicFrame):
     src = """
     <nvGraphicFramePr>
       <cNvPr id="0" name="Chart 0"></cNvPr>
       <cNvGraphicFramePr></cNvGraphicFramePr>
     </nvGraphicFramePr>
     """
     node = fromstring(src)
     graphic = NonVisualGraphicFrame.from_tree(node)
     assert graphic == NonVisualGraphicFrame()
コード例 #30
0
 def test_read(self, ChartsheetProperties):
     src = """
     <sheetPr codeName="Chart1">
       <tabColor rgb="FFDCD8F4" />
     </sheetPr>
     """
     xml = fromstring(src)
     chartsheetPr = ChartsheetProperties.from_tree(xml)
     assert chartsheetPr.codeName == "Chart1"
     assert chartsheetPr.tabColor.rgb == "FFDCD8F4"