Python openpyxl.__version__() Examples
The following are 8
code examples of openpyxl.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
openpyxl
, or try the search function
.
Example #1
Source File: openpyxl_compat.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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))
Example #2
Source File: excel.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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))
Example #3
Source File: openpyxl_compat.py From elasticintel with GNU General Public License v3.0 | 6 votes |
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))
Example #4
Source File: excel.py From elasticintel with GNU General Public License v3.0 | 6 votes |
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))
Example #5
Source File: version.py From StyleFrame with MIT License | 5 votes |
def get_openpyxl_version(): from openpyxl import __version__ as openpyxl_version return 'openpyxl {}'.format(openpyxl_version)
Example #6
Source File: test_excel.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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
Example #7
Source File: test_excel.py From elasticintel with GNU General Public License v3.0 | 5 votes |
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
Example #8
Source File: test_excel.py From elasticintel with GNU General Public License v3.0 | 3 votes |
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