Skip to content

Commit 5160de7

Browse files
author
Jesse Traas
committed
Prevent Excel export from generating two sheets
Previously, the Excel export created a new sheet after creating the workbook, but the Workbook constructor already creates a default sheet. This caused customers to open the export and see the first, empty sheet, thinking the export was broken rather than clicking on the second sheet.
1 parent e4c246e commit 5160de7

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

binder/plugins/views/csvexport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def get_response(self) -> HttpResponse:
9191

9292
class ExcelFileAdapter(ExportFileAdapter):
9393
"""
94-
Adapter fore returning excel files
94+
Adapter for returning excel files
9595
"""
9696
def __init__(self, request: HttpRequest):
9797
super().__init__(request)
@@ -103,7 +103,7 @@ def __init__(self, request: HttpRequest):
103103
# self.writer = self.pandas.ExcelWriter(self.response)
104104

105105
self.work_book = self.openpyxl.Workbook()
106-
self.sheet = self.work_book.create_sheet()
106+
self.sheet = self.work_book.active
107107

108108
# The row number we are currently writing to
109109
self._row_number = 0

tests/plugins/test_csvexport.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_excel_download(self):
7070
tmp.write(response.content)
7171

7272
wb = openpyxl.load_workbook(tmp.name)
73-
sheet = wb._sheets[1]
73+
sheet = wb._sheets[0]
7474

7575
_values = list(sheet.values)
7676

@@ -133,7 +133,7 @@ def test_context_aware_download_xlsx(self):
133133
tmp.write(response.content)
134134

135135
wb = openpyxl.load_workbook(tmp.name)
136-
sheet = wb._sheets[1]
136+
sheet = wb._sheets[0]
137137

138138
_values = list(sheet.values)
139139

0 commit comments

Comments
 (0)