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


Python Element.set方法代码示例

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


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

示例1: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import set [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

示例2: to_tree

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import set [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

示例3: append

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import set [as 别名]
    def append(self, row):
        """
        :param row: iterable containing values to append
        :type row: iterable
        """
        if (not isgenerator(row) and
            not isinstance(row, (list, tuple, range))
            ):
            self._invalid_row(row)
        cell = WriteOnlyCell(self)  # singleton

        self._max_row += 1
        row_idx = self._max_row
        if self.writer is None:
            self.writer = self._write_header()
            next(self.writer)

        el = Element("row", r='%d' % self._max_row)

        col_idx = None
        for col_idx, value in enumerate(row, 1):
            if value is None:
                continue
            try:
                cell.value = value
            except ValueError:
                if isinstance(value, Cell):
                    cell = value
                    if cell.comment is not None:
                        comment = cell.comment
                        comment._parent = CommentParentCell(cell)
                        self._comments.append(comment)
                else:
                    raise ValueError

            cell.col_idx = col_idx
            cell.row = row_idx

            styled = cell.has_style
            tree = write_cell(self, cell, styled)
            el.append(tree)
            if styled: # styled cell or datetime
                cell = WriteOnlyCell(self)

        if col_idx:
            self._max_col = max(self._max_col, col_idx)
            el.set('spans', '1:%d' % col_idx)
        try:
            self.writer.send(el)
        except StopIteration:
            self._already_saved()
开发者ID:Ivanych999,项目名称:UniumPlugin,代码行数:53,代码来源:write_only.py

示例4: write_string_table

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import set [as 别名]
def write_string_table(string_table):
    """Write the string table xml."""
    out = BytesIO()

    with xmlfile(out) as xf:
        with xf.element("sst", xmlns=SHEET_MAIN_NS, uniqueCount="%d" % len(string_table)):

            for key in string_table:
                el = Element('si')
                if key.strip() != key:
                    el.set(PRESERVE_SPACE, 'preserve')
                text = SubElement(el, 't')
                text.text = key
                xf.write(el)

    return  out.getvalue()
开发者ID:BlueMoon3000,项目名称:election-2016,代码行数:18,代码来源:strings.py

示例5: append

# 需要导入模块: from openpyxl.xml.functions import Element [as 别名]
# 或者: from openpyxl.xml.functions.Element import set [as 别名]
    def append(self, row):
        """
        :param row: iterable containing values to append
        :type row: iterable
        """
        if not isgenerator(row) and not isinstance(row, (list, tuple, range)):
            self._invalid_row(row)
        cell = WriteOnlyCell(self)  # singleton

        self._max_row += 1
        row_idx = self._max_row
        if self.writer is None:
            self.writer = self._write_header()
            next(self.writer)

        el = Element("row", r="%d" % self._max_row)

        col_idx = None
        for col_idx, value in enumerate(row, 1):
            if value is None:
                continue
            column = get_column_letter(col_idx)

            if isinstance(value, Cell):
                cell = value
            else:
                cell.value = value

            cell.coordinate = "%s%d" % (column, row_idx)
            if cell.comment is not None:
                comment = cell.comment
                comment._parent = CommentParentCell(cell)
                self._comments.append(comment)

            tree = write_cell(self, cell)
            el.append(tree)
            if cell.has_style:  # styled cell or datetime
                cell = WriteOnlyCell(self)

        if col_idx:
            self._max_col = max(self._max_col, col_idx)
            el.set("spans", "1:%d" % col_idx)
        try:
            self.writer.send(el)
        except StopIteration:
            self._already_saved()
开发者ID:sadatned,项目名称:Network_Latency_Monitoring_Tool,代码行数:48,代码来源:dump_worksheet.py

示例6: write_cols

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

    <cols> may never be empty -
    spec says must contain at least one child
    """

    def sorter(value):
        return column_index_from_string(value[0])

    el = Element('cols')
    obj = None

    for idx, col in sorted(worksheet.column_dimensions.items(), key=sorter):
        if dict(col) == {}:
            continue
        idx = column_index_from_string(idx)
        obj = Element('col', dict(col))
        obj.set('min', '%d' % (col.min or idx))
        obj.set('max', '%d' % (col.max or idx))
        el.append(obj)

    if obj is not None:
        return el
开发者ID:BespokeInsights,项目名称:openpyxl,代码行数:26,代码来源:worksheet.py


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