diff options
| author | Claude Paroz <claude@2xlibre.net> | 2019-10-04 20:32:01 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2019-10-04 20:46:31 +0200 |
| commit | 91062672b5406972da75bdcf02ad8373fff96377 (patch) | |
| tree | 2ced8643acabcb9238d9c47d45f4ceea86439d2d /tablib/formats/_xlsx.py | |
| parent | 34334e72a12c28425aff9162da13c3300bb80e18 (diff) | |
| download | tablib-91062672b5406972da75bdcf02ad8373fff96377.tar.gz | |
Fixed #373 - Properly detect xlsx format
Diffstat (limited to 'tablib/formats/_xlsx.py')
| -rw-r--r-- | tablib/formats/_xlsx.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 6662a2f..516191c 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -22,8 +22,11 @@ extensions = ('xlsx',) def detect(stream): """Returns True if given stream is a readable excel file.""" + if isinstance(stream, bytes): + # load_workbook expects a file-like object. + stream = BytesIO(stream) try: - openpyxl.reader.excel.load_workbook(stream) + openpyxl.reader.excel.load_workbook(stream, read_only=True) return True except openpyxl.shared.exc.InvalidFileException: pass |
