不知道如果你是立足于一个教程或没有这方面的努力,但Style
不是2.4.8 openpyxl
版本openpyxl.styles
可用的选项。
这里我导入openpyxl.styles,然后检查使用dir()
函数可用的所有选项。
如您所知,像Font
,PatternFill
等项目存在,但Style
不是。
In [2]: import openpyxl.styles as os
In [3]: dir(os)
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表明Style
被弃用:
这section of the openpyxl documentation对使用风格的一些指导。其中描述了您尝试实现的内容。
请务必使用您正在使用的版本的正确文档。 –