本文整理汇总了Python中pandas.io.formats.excel.CSSToExcelConverter方法的典型用法代码示例。如果您正苦于以下问题:Python excel.CSSToExcelConverter方法的具体用法?Python excel.CSSToExcelConverter怎么用?Python excel.CSSToExcelConverter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.formats.excel
的用法示例。
在下文中一共展示了excel.CSSToExcelConverter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_css_to_excel_multiple
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel_multiple():
convert = CSSToExcelConverter()
actual = convert('''
font-weight: bold;
text-decoration: underline;
color: red;
border-width: thin;
text-align: center;
vertical-align: top;
unused: something;
''')
assert {"font": {"bold": True, "underline": "single", "color": "FF0000"},
"border": {"top": {"style": "thin"},
"right": {"style": "thin"},
"bottom": {"style": "thin"},
"left": {"style": "thin"}},
"alignment": {"horizontal": "center",
"vertical": "top"}} == actual
示例2: test_css_to_excel_bad_colors
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel_bad_colors(input_color):
# see gh-18392
css = ("border-top-color: {color}; "
"border-right-color: {color}; "
"border-bottom-color: {color}; "
"border-left-color: {color}; "
"background-color: {color}; "
"color: {color}").format(color=input_color)
expected = dict()
if input_color is not None:
expected["fill"] = {
"patternType": "solid"
}
with tm.assert_produces_warning(CSSWarning):
convert = CSSToExcelConverter()
assert expected == convert(css)
示例3: test_css_to_excel_bad_colors
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel_bad_colors(input_color):
# see gh-18392
css = ("border-top-color: {color}; "
"border-right-color: {color}; "
"border-bottom-color: {color}; "
"border-left-color: {color}; "
"background-color: {color}; "
"color: {color}").format(color=input_color)
expected = dict()
if input_color is not None:
expected["fill"] = {
"patternType": "solid"
}
with catch_warnings(record=True):
convert = CSSToExcelConverter()
assert expected == convert(css)
示例4: test_css_to_excel
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel(css, expected):
convert = CSSToExcelConverter()
assert expected == convert(css)
示例5: test_css_to_excel_inherited
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel_inherited(css, inherited, expected):
convert = CSSToExcelConverter(inherited)
assert expected == convert(css)
示例6: test_css_to_excel_good_colors
# 需要导入模块: from pandas.io.formats import excel [as 别名]
# 或者: from pandas.io.formats.excel import CSSToExcelConverter [as 别名]
def test_css_to_excel_good_colors(input_color, output_color):
# see gh-18392
css = ("border-top-color: {color}; "
"border-right-color: {color}; "
"border-bottom-color: {color}; "
"border-left-color: {color}; "
"background-color: {color}; "
"color: {color}").format(color=input_color)
expected = dict()
expected["fill"] = {
"patternType": "solid",
"fgColor": output_color
}
expected["font"] = {
"color": output_color
}
expected["border"] = {
k: {
"color": output_color,
} for k in ("top", "right", "bottom", "left")
}
with tm.assert_produces_warning(None):
convert = CSSToExcelConverter()
assert expected == convert(css)