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


Python SubElement.attrib["count"]方法代码示例

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


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

示例1: _write_fonts

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_fonts(self):
        """ add fonts part to root
            return {font.crc => index}
        """

        fonts = SubElement(self._root, 'fonts')

        # default
        font_node = SubElement(fonts, 'font')
        SubElement(font_node, 'sz', {'val':'11'})
        SubElement(font_node, 'color', {'theme':'1'})
        SubElement(font_node, 'name', {'val':'Calibri'})
        SubElement(font_node, 'family', {'val':'2'})
        SubElement(font_node, 'scheme', {'val':'minor'})

        # others
        table = {}
        index = 1
        for st in self.styles:
            if st.font != DEFAULTS.font and st.font not in table:
                font_node = SubElement(fonts, 'font')
                table[st.font] = index
                index += 1
                self._write_font(font_node, st.font)

        fonts.attrib["count"] = "%d" % index
        return table
开发者ID:LKI,项目名称:PythonScripts,代码行数:29,代码来源:styles.py

示例2: _write_borders

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_borders(self):
        borders = SubElement(self._root, 'borders')

        # default
        border = SubElement(borders, 'border')
        SubElement(border, 'left')
        SubElement(border, 'right')
        SubElement(border, 'top')
        SubElement(border, 'bottom')
        SubElement(border, 'diagonal')

        # others
        table = {}
        index = 1
        for st in self._style_list:
            if st.borders != DEFAULTS.borders and st.borders not in table:
                table[st.borders] = index
                border = SubElement(borders, 'border')
                # caution: respect this order
                for side in ('left', 'right', 'top', 'bottom', 'diagonal'):
                    obj = getattr(st.borders, side)
                    if obj.border_style is None or obj.border_style == 'none':
                        node = SubElement(border, side)
                    else:
                        node = SubElement(border, side, {'style':obj.border_style})
                        self._unpack_color(node, obj.color.index)

                index += 1

        borders.attrib["count"] = str(index)
        return table
开发者ID:ericgazoni,项目名称:openpyxl,代码行数:33,代码来源:styles.py

示例3: _write_fills

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_fills(self):
        fills = SubElement(self._root, 'fills', {'count':'2'})
        fill = SubElement(fills, 'fill')
        SubElement(fill, 'patternFill', {'patternType':'none'})
        fill = SubElement(fills, 'fill')
        SubElement(fill, 'patternFill', {'patternType':'gray125'})

        table = {}
        index = 2
        for st in self._style_list:
            if st.fill != DEFAULTS.fill and st.fill not in table:
                table[st.fill] = index
                fill = SubElement(fills, 'fill')
                if st.fill.fill_type != DEFAULTS.fill.fill_type:
                    node = SubElement(fill, 'patternFill', {'patternType':st.fill.fill_type})
                    if st.fill.start_color != DEFAULTS.fill.start_color:
                        self._unpack_color(node, st.fill.start_color.index, 'fgColor')

                    if st.fill.end_color != DEFAULTS.fill.end_color:
                        self._unpack_color(node, st.fill.end_color.index, 'bgColor')

                index += 1

        fills.attrib["count"] = str(index)
        return table
开发者ID:ericgazoni,项目名称:openpyxl,代码行数:27,代码来源:styles.py

示例4: _write_fills

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_fills(self):
        fills = SubElement(self._root, 'fills', {'count':'2'})
        fill = SubElement(fills, 'fill')
        SubElement(fill, 'patternFill', {'patternType':'none'})
        fill = SubElement(fills, 'fill')
        SubElement(fill, 'patternFill', {'patternType':'gray125'})

        table = {}
        index = 2
        for st in self.styles:
            if st.fill != DEFAULTS.fill and st.fill not in table:

                table[st.fill] = index
                node = SubElement(fills, 'fill')
                if isinstance(st.fill, PatternFill):
                    self._write_pattern_fill(node, st.fill)
                elif isinstance(st.fill, GradientFill):
                    self._write_gradient_fill(node, st.fill)
                index += 1

        fills.attrib["count"] = str(index)
        return table
开发者ID:LKI,项目名称:PythonScripts,代码行数:24,代码来源:styles.py

示例5: _write_borders

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_borders(self):
        borders = SubElement(self._root, 'borders')

        # default
        border = SubElement(borders, 'border')
        SubElement(border, 'left')
        SubElement(border, 'right')
        SubElement(border, 'top')
        SubElement(border, 'bottom')
        SubElement(border, 'diagonal')

        # others
        table = {}
        index = 1
        for st in self.styles:
            if st.border != DEFAULTS.border and st.border not in table:
                table[st.border] = index
                self._write_border(borders, st.border)
                index += 1

        borders.attrib["count"] = str(index)
        return table
开发者ID:LKI,项目名称:PythonScripts,代码行数:24,代码来源:styles.py

示例6: _write_fonts

# 需要导入模块: from openpyxl.xml.functions import SubElement [as 别名]
# 或者: from openpyxl.xml.functions.SubElement import attrib["count"] [as 别名]
    def _write_fonts(self):
        """ add fonts part to root
            return {font.crc => index}
        """

        fonts = SubElement(self._root, 'fonts')

        # default
        font_node = SubElement(fonts, 'font')
        SubElement(font_node, 'sz', {'val':'11'})
        SubElement(font_node, 'color', {'theme':'1'})
        SubElement(font_node, 'name', {'val':'Calibri'})
        SubElement(font_node, 'family', {'val':'2'})
        SubElement(font_node, 'scheme', {'val':'minor'})

        # others
        table = {}
        index = 1
        for st in self._style_list:
            if st.font != DEFAULTS.font and st.font not in table:
                table[st.font] = index
                font_node = SubElement(fonts, 'font')
                SubElement(font_node, 'sz', {'val':str(st.font.size)})
                self._unpack_color(font_node, st.font.color.index)
                SubElement(font_node, 'name', {'val':st.font.name})
                SubElement(font_node, 'family', {'val':'2'})
                # Don't write the 'scheme' element because it appears to prevent
                # the font name from being applied in Excel.
                #SubElement(font_node, 'scheme', {'val':'minor'})
                ConditionalElement(font_node, "b", st.font.bold)
                ConditionalElement(font_node, "i", st.font.italic)
                ConditionalElement(font_node, "u",  st.font.underline == 'single')

                index += 1

        fonts.attrib["count"] = str(index)
        return table
开发者ID:ericgazoni,项目名称:openpyxl,代码行数:39,代码来源:styles.py


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