当前位置: 首页>>代码示例>>Python>>正文


Python Element.append方法代码示例

本文整理汇总了Python中openpyxl.xml.functions.Element.append方法的典型用法代码示例。如果您正苦于以下问题:Python Element.append方法的具体用法?Python Element.append怎么用?Python Element.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openpyxl.xml.functions.Element的用法示例。


在下文中一共展示了Element.append方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write_comments_vml

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
    def write_comments_vml(self):
        root = Element("xml")
        shape_layout = SubElement(root, "{%s}shapelayout" % officens,
                                  {"{%s}ext" % vmlns: "edit"})
        SubElement(shape_layout,
                   "{%s}idmap" % officens,
                   {"{%s}ext" % vmlns: "edit", "data": "1"})
        shape_type = SubElement(root,
                                "{%s}shapetype" % vmlns,
                                {"id": "_x0000_t202",
                                 "coordsize": "21600,21600",
                                 "{%s}spt" % officens: "202",
                                 "path": "m,l,21600r21600,l21600,xe"})
        SubElement(shape_type, "{%s}stroke" % vmlns, {"joinstyle": "miter"})
        SubElement(shape_type,
                   "{%s}path" % vmlns,
                   {"gradientshapeok": "t",
                    "{%s}connecttype" % officens: "rect"})

        for idx, comment in enumerate(self.comments, 1026):

            shape = _shape_factory()
            col, row = coordinate_from_string(comment.ref)
            row -= 1
            column = column_index_from_string(col) - 1

            shape.set('id',  "_x0000_s%04d" % idx)
            client_data = shape.find("{%s}ClientData" % excelns)
            client_data.find("{%s}Row" % excelns).text = str(row)
            client_data.find("{%s}Column" % excelns).text = str(column)
            root.append(shape)

        return tostring(root)
开发者ID:Ivanych999,项目名称:UniumPlugin,代码行数:35,代码来源:writer.py

示例2: write_external_book_rel

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_external_book_rel(book):
    """Serialise link to external file"""
    root = Element("Relationships", xmlns=PKG_REL_NS)
    rel = Relationship("", target=book.Target, targetMode=book.TargetMode, id="rId1")
    rel.type = book.Type
    root.append(rel.to_tree())
    return root
开发者ID:CometHale,项目名称:lphw,代码行数:9,代码来源:external.py

示例3: write_rels

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_rels(worksheet, comments_id=None, vba_controls_id=None):
    """Write relationships for the worksheet to xml."""
    root = Element('Relationships', xmlns=PKG_REL_NS)
    rels = worksheet._rels

    # VBA
    if worksheet.vba_controls is not None:
        rel = Relationship("vmlDrawing", id=worksheet.vba_controls,
                           target='/xl/drawings/vmlDrawing%s.vml' % vba_controls_id)
        rels.append(rel)

    # Comments
    if worksheet._comment_count > 0:
        rel = Relationship(type="comments", id="comments",
                           target='/xl/comments%s.xml' % comments_id)
        rels.append(rel)

        if worksheet.vba_controls is None:
            rel = Relationship(type="vmlDrawing", id="commentsvml",
                           target='/xl/drawings/commentsDrawing%s.vml' % comments_id)
            rels.append(rel)

    for idx, rel in enumerate(rels, 1):
        if rel.id is None:
            rel.id = "rId{0}".format(idx)
        root.append(rel.to_tree())

    return root
开发者ID:18600597055,项目名称:hue,代码行数:30,代码来源:relations.py

示例4: write_external_book_rel

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_external_book_rel(book):
    """Serialise link to external file"""
    root = Element("{%s}Relationships" % PKG_REL_NS)
    attrs = {"Id":"rId1", "Target":book.Target, "TargetMode":book.TargetMode,
             "Type":book.Type}
    root.append(RelationElement(attrs))
    return root
开发者ID:Hitachi-Data-Systems,项目名称:org-chart-builder,代码行数:9,代码来源:external.py

示例5: _write_header

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
    def _write_header(self):
        """
        Generator that creates the XML file and the sheet header
        """

        with xmlfile(self.filename) as xf:
            with xf.element("worksheet", xmlns=SHEET_MAIN_NS):

                if self.sheet_properties:
                    pr = write_sheetPr(self.sheet_properties)

                xf.write(pr)
                views = Element("sheetViews")
                views.append(self.sheet_view.to_tree())
                xf.write(views)
                xf.write(write_format(self))

                cols = write_cols(self)
                if cols is not None:
                    xf.write(cols)

                with xf.element("sheetData"):
                    try:
                        while True:
                            r = (yield)
                            xf.write(r)
                    except GeneratorExit:
                        pass
                af = write_autofilter(self)
                if af is not None:
                    xf.write(af)
                if self._comments:
                    comments = Element("legacyDrawing", {"{%s}id" % REL_NS: "commentsvml"})
                    xf.write(comments)
开发者ID:sadatned,项目名称:Network_Latency_Monitoring_Tool,代码行数:36,代码来源:dump_worksheet.py

示例6: write_cols

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_cols(worksheet):
    """Write worksheet columns to xml.

    <cols> may never be empty -
    spec says must contain at least one child
    """
    cols = []
    for label, dimension in iteritems(worksheet.column_dimensions):
        col_def = dict(dimension)
        if col_def == {}:
            continue
        idx = column_index_from_string(label)
        cols.append((idx, col_def))

    if not cols:
        return

    el = Element('cols')

    for idx, col_def in sorted(cols):
        v = "%d" % idx
        cmin = col_def.get('min') or v
        cmax = col_def.get('max') or v
        col_def.update({'min': cmin, 'max': cmax})
        el.append(Element('col', col_def))
    return el
开发者ID:indoorvoice,项目名称:WiFinder,代码行数:28,代码来源:worksheet.py

示例7: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
 def to_tree(self, tagname, obj, namespace=None):
     tagname = namespaced(self, tagname, namespace)
     container = Element(tagname)
     if self.count:
         container.set('count', str(len(obj)))
     for v in obj:
         container.append(v.to_tree())
     return container
开发者ID:JLL-Benson,项目名称:CHN_DQ,代码行数:10,代码来源:sequence.py

示例8: _serialise_nested

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
 def _serialise_nested(self, sequence):
     """
     Colors need special handling
     """
     for idx, color in enumerate(sequence):
         stop = Element("stop", position=str(idx))
         stop.append(color.to_tree())
         yield stop
开发者ID:BlueMoon3000,项目名称:election-2016,代码行数:10,代码来源:fills.py

示例9: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
    def to_tree(self):
        tree = Element("Relationships", xmlns=PKG_REL_NS)
        for idx, rel in enumerate(self.Relationship, 1):
            if not rel.Id:
                rel.Id = "rId{0}".format(idx)
            tree.append(rel.to_tree())

        return tree
开发者ID:jingchenw,项目名称:Procura-to-ClientCare,代码行数:10,代码来源:relationship.py

示例10: write_pagebreaks

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_pagebreaks(worksheet):
    breaks = worksheet.page_breaks
    if breaks:
        tag = Element('rowBreaks', {'count': str(len(breaks)),
                                     'manualBreakCount': str(len(breaks))})
        for b in breaks:
            tag.append(Element('brk', id=str(b), man="true", max='16383',
                               min='0'))
        return tag
开发者ID:indoorvoice,项目名称:WiFinder,代码行数:11,代码来源:worksheet.py

示例11: write_properties

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_properties(worksheet, vba_attrs):
    pr = Element('sheetPr', vba_attrs)
    summary = Element('outlinePr',
                      summaryBelow='%d' % worksheet.show_summary_below,
                      summaryRight= '%d' % worksheet.show_summary_right)
    pr.append(summary)
    if worksheet.page_setup.fitToPage:
        pr.append(Element('pageSetUpPr', fitToPage='1'))
    return pr
开发者ID:Hitachi-Data-Systems,项目名称:org-chart-builder,代码行数:11,代码来源:worksheet.py

示例12: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
 def to_tree(self, tagname=None):
     parent = Element("fill")
     el = Element(self.tagname, patternType=safe_string(self.patternType))
     for c in self.__elements__:
         value = getattr(self, c)
         if value != Color():
             el.append(value.to_tree(c))
     parent.append(el)
     return parent
开发者ID:azedlee,项目名称:nbastats,代码行数:11,代码来源:fills.py

示例13: write_mergecells

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_mergecells(worksheet):
    """Write merged cells to xml."""
    cells = worksheet._merged_cells
    if not cells:
        return

    merge = Element('mergeCells', count='%d' % len(cells))
    for range_string in cells:
        merge.append(Element('mergeCell', ref=range_string))
    return merge
开发者ID:BespokeInsights,项目名称:openpyxl,代码行数:12,代码来源:worksheet.py

示例14: write_hyperlinks

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
def write_hyperlinks(worksheet):
    """Write worksheet hyperlinks to xml."""
    tag = Element('hyperlinks')
    for cell in worksheet.get_cell_collection():
        if cell.hyperlink_rel_id is not None:
            attrs = {'display': cell.hyperlink,
                     'ref': cell.coordinate,
                     '{%s}id' % REL_NS: cell.hyperlink_rel_id}
            tag.append(Element('hyperlink', attrs))
    if tag.getchildren():
        return tag
开发者ID:indoorvoice,项目名称:WiFinder,代码行数:13,代码来源:worksheet.py

示例15: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import append [as 别名]
 def to_tree(self, tagname=None):
     parent = Element("fill")
     el = Element(self.tagname)
     if self.patternType is not None:
         el.set('patternType', self.patternType)
     for c in self.__elements__:
         value = getattr(self, c)
         if value != Color():
             el.append(value.to_tree(c))
     parent.append(el)
     return parent
开发者ID:CometHale,项目名称:lphw,代码行数:13,代码来源:fills.py


注:本文中的openpyxl.xml.functions.Element.append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。