diff options
| author | Timo Furrer <tuxtimo@gmail.com> | 2019-03-02 13:03:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-03-02 13:03:30 +0100 |
| commit | dc24fda41505d9961cd43939893a1cea3598ad18 (patch) | |
| tree | 65722f2695bb273494b198815320aec15d57b40e /tablib | |
| parent | 3ba8d529fc814833108f351fd8191e22fd0fc9e8 (diff) | |
| parent | f812c29275c7f47b08f8f1b962625545ec4e22ad (diff) | |
| download | tablib-dc24fda41505d9961cd43939893a1cea3598ad18.tar.gz | |
Merge pull request #333 from hudgeon/master
Updated xlsx format to remove reference to openpyxl's deprecated get_active_worksheet
Diffstat (limited to 'tablib')
| -rw-r--r-- | tablib/core.py | 16 | ||||
| -rw-r--r-- | tablib/formats/_xlsx.py | 2 |
2 files changed, 15 insertions, 3 deletions
diff --git a/tablib/core.py b/tablib/core.py index 6420ffa..809bb6e 100644 --- a/tablib/core.py +++ b/tablib/core.py @@ -527,9 +527,9 @@ class Dataset(object): Import assumes (for now) that headers exist. - .. admonition:: Binary Warning + .. admonition:: Binary Warning for Python 2 - :class:`Dataset.csv` uses \\r\\n line endings by default, so make + :class:`Dataset.csv` uses \\r\\n line endings by default so, in Python 2, make sure to write in binary mode:: with open('output.csv', 'wb') as f: @@ -537,6 +537,18 @@ class Dataset(object): If you do not do this, and you export the file on Windows, your CSV file will open in Excel with a blank line between each row. + + .. admonition:: Line endings for Python 3 + + :class:`Dataset.csv` uses \\r\\n line endings by default so, in Python 3, make + sure to include newline='' otherwise you will get a blank line between each row + when you open the file in Excel:: + + with open('output.csv', 'w', newline='') as f: + f.write(data.csv) + + If you do not do this, and you export the file on Windows, your + CSV file will open in Excel with a blank line between each row. """ pass diff --git a/tablib/formats/_xlsx.py b/tablib/formats/_xlsx.py index 1d29ba8..816fd37 100644 --- a/tablib/formats/_xlsx.py +++ b/tablib/formats/_xlsx.py @@ -71,7 +71,7 @@ def import_set(dset, in_stream, headers=True): dset.wipe() xls_book = openpyxl.reader.excel.load_workbook(BytesIO(in_stream)) - sheet = xls_book.get_active_sheet() + sheet = xls_book.active dset.title = sheet.title |
