diff options
| author | Wes <wes.stclair@gmail.com> | 2015-11-09 06:45:28 -0700 |
|---|---|---|
| committer | Wes <wes.stclair@gmail.com> | 2015-11-09 06:45:28 -0700 |
| commit | 1fcb98f9aee0d580bab42f233ee11d34891cb17b (patch) | |
| tree | 510218f65421e38c2338f7521e5e92075f528c5d | |
| parent | a785d77901f307ef499621753b078743e2fabb81 (diff) | |
| download | tablib-1fcb98f9aee0d580bab42f233ee11d34891cb17b.tar.gz | |
Fix XLSX import
Calling import_set on an XLSX file was throwing a TypeError from
Openpyxl. Openpyxl Reader load_workbook requires a file-like object as the first
argument. This commit fixes the error by passing in a file-like object
instead of a string.
| -rw-r--r-- | tablib/formats/_xlsx.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 57058c8..34e83e6 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -69,7 +69,7 @@ def import_set(dset, in_stream, headers=True): dset.wipe() - xls_book = openpyxl.reader.excel.load_workbook(in_stream) + xls_book = openpyxl.reader.excel.load_workbook(BytesIO(in_stream)) sheet = xls_book.get_active_sheet() dset.title = sheet.title @@ -87,7 +87,7 @@ def import_book(dbook, in_stream, headers=True): dbook.wipe() - xls_book = openpyxl.reader.excel.load_workbook(in_stream) + xls_book = openpyxl.reader.excel.load_workbook(BytesIO(in_stream)) for sheet in xls_book.worksheets: data = tablib.Dataset() |
