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


Python styles.Color方法代码示例

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


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

示例1: to_openpyxl_style

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def to_openpyxl_style(self):
        try:
            openpyxl_style = self.cache[self]
        except KeyError:
            side = Side(border_style=self.border_type, color=utils.colors.black)
            border = Border(left=side, right=side, top=side, bottom=side)
            openpyxl_style = self.cache[self] = NamedStyle(
                name=str(hash(self)),
                font=Font(name=self.font, size=self.font_size, color=OpenPyColor(self.font_color),
                          bold=self.bold, underline=self.underline),
                fill=PatternFill(patternType=self.fill_pattern_type, fgColor=self.bg_color),
                alignment=Alignment(horizontal=self.horizontal_alignment, vertical=self.vertical_alignment,
                                    wrap_text=self.wrap_text, shrink_to_fit=self.shrink_to_fit,
                                    indent=self.indent, text_rotation=self.text_rotation),
                border=border,
                number_format=self.number_format,
                protection=Protection(locked=self.protection)
            )
        return openpyxl_style 
开发者ID:DeepSpace2,项目名称:StyleFrame,代码行数:21,代码来源:styler.py

示例2: __init__

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def __init__(self, start_type, start_value, start_color, end_type, end_value, end_color,
                 mid_type=None, mid_value=None, mid_color=None, columns_range=None):

        self.columns = columns_range

        # checking against None explicitly since mid_value may be 0
        if all(val is not None for val in (mid_type, mid_value, mid_color)):
            self.rule = ColorScaleRule(start_type=start_type, start_value=start_value,
                                       start_color=OpenPyColor(start_color),
                                       mid_type=mid_type, mid_value=mid_value,
                                       mid_color=OpenPyColor(mid_color),
                                       end_type=end_type, end_value=end_value,
                                       end_color=OpenPyColor(end_color))
        else:
            self.rule = ColorScaleRule(start_type=start_type, start_value=start_value,
                                       start_color=OpenPyColor(start_color),
                                       end_type=end_type, end_value=end_value,
                                       end_color=OpenPyColor(end_color)) 
开发者ID:DeepSpace2,项目名称:StyleFrame,代码行数:20,代码来源:styler.py

示例3: get_cell_style

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def get_cell_style(color='FF000000', bgcolor='FFFFFFFF', font='Calibri', size=11, bold=False, italic=False,
                       underline='none', strike=False, border=None, border_style=BORDER_THIN, border_bottom=None,
                       border_bottom_style=None, horizontal='general', vertical='bottom', number_format=None):
        if not border:
            border = 'FFB6B6B4'
        if not border_bottom:
            border_bottom = border
        if not border_bottom_style:
            border_bottom_style = border_style
        return Style(font=Font(name=font, size=size, bold=bold, italic=italic, vertAlign=None, underline=underline,
                               strike=strike, color=color),
                     fill=PatternFill(patternType='solid', fgColor=Color(bgcolor)),
                     border=Border(
                         left=Side(border_style=border_style, color=Color(border)),
                         right=Side(border_style=border_style, color=Color(border)),
                         top=Side(border_style=border_style, color=Color(border)),
                         bottom=Side(border_style=border_bottom_style, color=Color(border_bottom)),),
                     alignment=Alignment(horizontal=horizontal, vertical=vertical, text_rotation=0, wrap_text=False,
                                         shrink_to_fit=False, indent=0),
                     number_format=number_format
                     ) 
开发者ID:erigones,项目名称:esdc-ce,代码行数:23,代码来源:excel.py

示例4: _convert_to_stop

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def _convert_to_stop(cls, stop_seq):
        """
        Convert ``stop_seq`` to a list of openpyxl v2 Color objects,
        suitable for initializing the ``GradientFill`` ``stop`` parameter.
        Parameters
        ----------
        stop_seq : iterable
            An iterable that yields objects suitable for consumption by
            ``_convert_to_color``.
        Returns
        -------
        stop : list of openpyxl.styles.Color
        """

        return map(cls._convert_to_color, stop_seq) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:excel.py

示例5: _convert_to_color

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def _convert_to_color(cls, color_spec):
        """
        Convert ``color_spec`` to an openpyxl v2 Color object
        Parameters
        ----------
        color_spec : str, dict
            A 32-bit ARGB hex string, or a dict with zero or more of the
            following keys.
                'rgb'
                'indexed'
                'auto'
                'theme'
                'tint'
                'index'
                'type'
        Returns
        -------
        color : openpyxl.styles.Color
        """

        from openpyxl.styles import Color

        if isinstance(color_spec, str):
            return Color(color_spec)
        else:
            return Color(**color_spec) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:28,代码来源:excel.py

示例6: test_to_excel_styleconverter

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def test_to_excel_styleconverter(self, merge_cells, ext, engine):
        from openpyxl import styles

        hstyle = {
            "font": {
                "color": '00FF0000',
                "bold": True,
            },
            "borders": {
                "top": "thin",
                "right": "thin",
                "bottom": "thin",
                "left": "thin",
            },
            "alignment": {
                "horizontal": "center",
                "vertical": "top",
            },
            "fill": {
                "patternType": 'solid',
                'fgColor': {
                    'rgb': '006666FF',
                    'tint': 0.3,
                },
            },
            "number_format": {
                "format_code": "0.00"
            },
            "protection": {
                "locked": True,
                "hidden": False,
            },
        }

        font_color = styles.Color('00FF0000')
        font = styles.Font(bold=True, color=font_color)
        side = styles.Side(style=styles.borders.BORDER_THIN)
        border = styles.Border(top=side, right=side, bottom=side, left=side)
        alignment = styles.Alignment(horizontal='center', vertical='top')
        fill_color = styles.Color(rgb='006666FF', tint=0.3)
        fill = styles.PatternFill(patternType='solid', fgColor=fill_color)

        number_format = '0.00'

        protection = styles.Protection(locked=True, hidden=False)

        kw = _OpenpyxlWriter._convert_to_style_kwargs(hstyle)
        assert kw['font'] == font
        assert kw['border'] == border
        assert kw['alignment'] == alignment
        assert kw['fill'] == fill
        assert kw['number_format'] == number_format
        assert kw['protection'] == protection 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:55,代码来源:test_excel.py

示例7: test_to_excel_styleconverter

# 需要导入模块: from openpyxl import styles [as 别名]
# 或者: from openpyxl.styles import Color [as 别名]
def test_to_excel_styleconverter(self):
        import openpyxl
        from openpyxl import styles

        hstyle = {
            "font": {
                "color": '00FF0000',
                "bold": True,
            },
            "borders": {
                "top": "thin",
                "right": "thin",
                "bottom": "thin",
                "left": "thin",
            },
            "alignment": {
                "horizontal": "center",
                "vertical": "top",
            },
            "fill": {
                "patternType": 'solid',
                'fgColor': {
                    'rgb': '006666FF',
                    'tint': 0.3,
                },
            },
            "number_format": {
                "format_code": "0.00"
            },
            "protection": {
                "locked": True,
                "hidden": False,
            },
        }

        font_color = styles.Color('00FF0000')
        font = styles.Font(bold=True, color=font_color)
        side = styles.Side(style=styles.borders.BORDER_THIN)
        border = styles.Border(top=side, right=side, bottom=side, left=side)
        alignment = styles.Alignment(horizontal='center', vertical='top')
        fill_color = styles.Color(rgb='006666FF', tint=0.3)
        fill = styles.PatternFill(patternType='solid', fgColor=fill_color)

        # ahh openpyxl API changes
        ver = openpyxl.__version__
        if ver >= LooseVersion('2.0.0') and ver < LooseVersion('2.1.0'):
            number_format = styles.NumberFormat(format_code='0.00')
        else:
            number_format = '0.00'  # XXX: Only works with openpyxl-2.1.0

        protection = styles.Protection(locked=True, hidden=False)

        kw = _Openpyxl20Writer._convert_to_style_kwargs(hstyle)
        assert kw['font'] == font
        assert kw['border'] == border
        assert kw['alignment'] == alignment
        assert kw['fill'] == fill
        assert kw['number_format'] == number_format
        assert kw['protection'] == protection 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:61,代码来源:test_excel.py


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