不确定您是否将此工作建立在教程的基础上,但是
Style
openpyxl.styles
对于
openpyxl
版本2.4.8。
dir()
作用
正如您所注意到的,以下项目
Font
,
PatternFill
风格
不是。
In [2]: import openpyxl.styles as ops
In [3]: dir(ops)
Out[3]:
['Alignment',
'Border',
'Color',
'DEFAULT_FONT',
'Fill',
'Font',
'GradientFill',
'NamedStyle',
'NumberFormatDescriptor',
'PatternFill',
'Protection',
'Side',
'__builtins__',
'__cached__',
'__doc__',
'__file__',
'__loader__',
'__name__',
'__package__',
'__path__',
'__spec__',
'absolute_import',
'alignment',
'borders',
'builtins',
'cell_style',
'colors',
'differential',
'fills',
'fonts',
'is_builtin',
'is_date_format',
'named_styles',
'numbers',
'protection',
'proxy',
'styleable',
'stylesheet',
'table']
这
stack overflow question
表明
风格
已弃用:
section of the openpyxl documentation
对使用风格有一些指导。这很可能是你试图实现的描述。