本文整理汇总了Python中openpyxl.__version__方法的典型用法代码示例。如果您正苦于以下问题:Python openpyxl.__version__方法的具体用法?Python openpyxl.__version__怎么用?Python openpyxl.__version__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openpyxl
的用法示例。
在下文中一共展示了openpyxl.__version__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: is_compat
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [as 别名]
def is_compat(major_ver=1):
"""Detect whether the installed version of openpyxl is supported
Parameters
----------
ver : int
1 requests compatibility status among the 1.x.y series
2 requests compatibility status of 2.0.0 and later
Returns
-------
compat : bool
``True`` if openpyxl is installed and is a compatible version.
``False`` otherwise.
"""
import openpyxl
ver = LooseVersion(openpyxl.__version__)
if major_ver == 1:
return LooseVersion(start_ver) <= ver < LooseVersion(stop_ver)
elif major_ver == 2:
return LooseVersion(stop_ver) <= ver
else:
raise ValueError('cannot test for openpyxl compatibility with ver {0}'
.format(major_ver))
示例2: get_writer
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [as 别名]
def get_writer(engine_name):
if engine_name == 'openpyxl':
try:
import openpyxl
# with version-less openpyxl engine
# make sure we make the intelligent choice for the user
if LooseVersion(openpyxl.__version__) < '2.0.0':
return _writers['openpyxl1']
elif LooseVersion(openpyxl.__version__) < '2.2.0':
return _writers['openpyxl20']
else:
return _writers['openpyxl22']
except ImportError:
# fall through to normal exception handling below
pass
try:
return _writers[engine_name]
except KeyError:
raise ValueError("No Excel writer '{engine}'"
.format(engine=engine_name))
示例3: get_openpyxl_version
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [as 别名]
def get_openpyxl_version():
from openpyxl import __version__ as openpyxl_version
return 'openpyxl {}'.format(openpyxl_version)
示例4: skip_openpyxl_gt21
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [as 别名]
def skip_openpyxl_gt21(cls):
"""Skip test case if openpyxl >= 2.2"""
@classmethod
def setup_class(cls):
_skip_if_no_openpyxl()
import openpyxl
ver = openpyxl.__version__
if (not (LooseVersion(ver) >= LooseVersion('2.0.0') and
LooseVersion(ver) < LooseVersion('2.2.0'))):
pytest.skip("openpyxl %s >= 2.2" % str(ver))
cls.setup_class = setup_class
return cls
示例5: skip_openpyxl_lt22
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [as 别名]
def skip_openpyxl_lt22(cls):
"""Skip test case if openpyxl < 2.2"""
@classmethod
def setup_class(cls):
_skip_if_no_openpyxl()
import openpyxl
ver = openpyxl.__version__
if LooseVersion(ver) < LooseVersion('2.2.0'):
pytest.skip("openpyxl %s < 2.2" % str(ver))
cls.setup_class = setup_class
return cls
示例6: test_to_excel_styleconverter
# 需要导入模块: import openpyxl [as 别名]
# 或者: from openpyxl import __version__ [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