本文整理汇总了Python中openpyxl.xml.functions.fromstring函数的典型用法代码示例。如果您正苦于以下问题:Python fromstring函数的具体用法?Python fromstring怎么用?Python fromstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fromstring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_from_xml
def test_from_xml(self, NonVisualDrawingProps):
src = """
<cNvPr id="3" name="Chart 2"></cNvPr>
"""
node = fromstring(src)
graphic = NonVisualDrawingProps.from_tree(node)
assert graphic == NonVisualDrawingProps(id=3, name="Chart 2")
示例2: read_content_types
def read_content_types(archive):
"""Read content types."""
xml_source = archive.read(ARC_CONTENT_TYPES)
root = fromstring(xml_source)
contents_root = root.findall('{%s}Override' % CONTYPES_NS)
for type in contents_root:
yield type.get('ContentType'), type.get('PartName')
示例3: test_from_xml
def test_from_xml(self, FunctionGroup):
src = """
<functionGroup name="Database" />
"""
node = fromstring(src)
function_group = FunctionGroup.from_tree(node)
assert function_group == FunctionGroup(name="Database")
示例4: parse
def parse(self):
src = self.archive.read(self.workbook_part_name)
node = fromstring(src)
package = WorkbookPackage.from_tree(node)
if package.properties.date1904:
self.wb.excel_base_date = CALENDAR_MAC_1904
self.wb.code_name = package.properties.codeName
self.wb.active = package.active
self.wb.views = package.bookViews
self.sheets = package.sheets
self.wb.calculation = package.calcPr
self.caches = package.pivotCaches
#external links contain cached worksheets and can be very big
if not self.wb.keep_links:
package.externalReferences = []
for ext_ref in package.externalReferences:
rel = self.rels[ext_ref.id]
self.wb._external_links.append(
read_external_link(self.archive, rel.Target)
)
if package.definedNames:
package.definedNames._cleanup()
self.wb.defined_names = package.definedNames
self.wb.security = package.workbookProtection
示例5: test_read_row
def test_read_row(datadir, DummyWorkbook, ReadOnlyWorksheet):
datadir.join("reader").chdir()
src = b"""
<sheetData xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" >
<row r="1" spans="4:27">
<c r="D1">
<v>1</v>
</c>
<c r="K1">
<v>0.01</v>
</c>
<c r="AA1">
<v>100</v>
</c>
</row>
</sheetData>
"""
ws = ReadOnlyWorksheet(DummyWorkbook, "Sheet", "", "bug393-worksheet.xml", [])
xml = fromstring(src)
row = tuple(ws._get_row(xml, 11, 11))
values = [c.value for c in row]
assert values == [0.01]
row = tuple(ws._get_row(xml, 1, 11))
values = [c.value for c in row]
assert values == [None, None, None, 1, None, None, None, None, None, None, 0.01]
示例6: test_from_xml
def test_from_xml(self, SmartTagProperties):
src = """
<smartTagPr />
"""
node = fromstring(src)
smart_tags = SmartTagProperties.from_tree(node)
assert smart_tags == SmartTagProperties()
示例7: test_read
def test_read(self, ChartsheetView):
src = """
<sheetView tabSelected="1" zoomScale="80" workbookViewId="0" zoomToFit="1"/>
"""
xml = fromstring(src)
chart = ChartsheetView.from_tree(xml)
assert chart.tabSelected == True
示例8: test_from_xml
def test_from_xml(self, WebPublishObjectList):
src = """
<webPublishingObjects />
"""
node = fromstring(src)
objs = WebPublishObjectList.from_tree(node)
assert objs == WebPublishObjectList()
示例9: test_from_xml
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 [a.val for a in chart.axId] == [10, 100, 1000]
示例10: test_from_xml
def test_from_xml(self, DefinedNameList):
src = """
<definedNames />
"""
node = fromstring(src)
names = DefinedNameList.from_tree(node)
assert names == DefinedNameList()
示例11: from_xml
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
示例12: test_from_xml
def test_from_xml(self, WorkbookProtection):
src = """
<workbookPr />
"""
node = fromstring(src)
prot = WorkbookProtection.from_tree(node)
assert prot == WorkbookProtection()
示例13: test_from_xml
def test_from_xml(self, Title):
src = """
<title />
"""
node = fromstring(src)
title = Title.from_tree(node)
assert title == Title()
示例14: test_from_xml
def test_from_xml(self, GradientFillProperties):
src = """
<gradFill></gradFill>
"""
node = fromstring(src)
fill = GradientFillProperties.from_tree(node)
assert fill == GradientFillProperties()
示例15: test_from_tree
def test_from_tree(self):
from ..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