From 35426b919e4474599106ffa8db47b7064b203827 Mon Sep 17 00:00:00 2001 From: Bojan Mihelac Date: Fri, 18 Dec 2015 09:50:00 +0100 Subject: [PATCH] openpyxl is required for xlsx --- import_export/formats/base_formats.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/import_export/formats/base_formats.py b/import_export/formats/base_formats.py index 10b5447eb..f5e7c2412 100644 --- a/import_export/formats/base_formats.py +++ b/import_export/formats/base_formats.py @@ -22,14 +22,12 @@ try: - from tablib.compat import openpyxl - + import openpyxl XLSX_IMPORT = True except ImportError: try: - import openpyxl # NOQA - - XLSX_IMPORT = True + from tablib.compat import openpyxl + XLSX_IMPORT = hasattr(openpyxl, 'load_workbook') except ImportError: xlsx_warning = "Installed `tablib` library does not include" "import support for 'xlsx' format and openpyxl module is not found." @@ -211,8 +209,7 @@ def create_dataset(self, in_stream): """ assert XLSX_IMPORT from io import BytesIO - from openpyxl import load_workbook - xlsx_book = load_workbook(BytesIO(in_stream)) + xlsx_book = openpyxl.load_workbook(BytesIO(in_stream)) dataset = tablib.Dataset() sheet = xlsx_book.active