Skip to content

Commit 8575e9e

Browse files
committed
Avoid some openpyxl warnings by not using deprecated method
1 parent a2e8cfa commit 8575e9e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

flattentool/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ class XLSXInput(SpreadsheetInput):
555555
def read_sheets(self):
556556
self.workbook = openpyxl.load_workbook(self.input_name, data_only=True)
557557

558-
self.sheet_names_map = OrderedDict((sheet_name, sheet_name) for sheet_name in self.workbook.get_sheet_names())
558+
self.sheet_names_map = OrderedDict((sheet_name, sheet_name) for sheet_name in self.workbook.sheetnames)
559559
if self.include_sheets:
560560
for sheet in list(self.sheet_names_map):
561561
if sheet not in self.include_sheets:

flattentool/tests/test_output.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def test_blank_sheets(tmpdir):
3232

3333
# Check XLSX is empty
3434
wb = openpyxl.load_workbook(tmpdir.join('release.xlsx').strpath)
35-
assert wb.get_sheet_names() == ['release']
35+
assert wb.sheetnames == ['release']
3636
rows = list(wb['release'].rows)
3737
assert len(rows) == 1
3838
assert len(rows[0]) == 1
@@ -55,7 +55,7 @@ def test_populated_header(tmpdir):
5555

5656
# Check XLSX
5757
wb = openpyxl.load_workbook(tmpdir.join('release.xlsx').strpath)
58-
assert wb.get_sheet_names() == ['release', 'b']
58+
assert wb.sheetnames == ['release', 'b']
5959
rows = list(wb['release'].rows)
6060
assert len(rows) == 1
6161
assert [ x.value for x in rows[0] ] == [ 'a', 'd' ]
@@ -86,7 +86,7 @@ def test_empty_lines(tmpdir):
8686

8787
# Check XLSX
8888
wb = openpyxl.load_workbook(tmpdir.join('release.xlsx').strpath)
89-
assert wb.get_sheet_names() == ['release', 'b']
89+
assert wb.sheetnames == ['release', 'b']
9090
rows = list(wb['release'].rows)
9191
assert len(rows) == 1
9292
assert [ x.value for x in rows[0] ] == [ 'a', 'd' ]
@@ -119,7 +119,7 @@ def test_populated_lines(tmpdir):
119119

120120
# Check XLSX
121121
wb = openpyxl.load_workbook(tmpdir.join('release.xlsx').strpath)
122-
assert wb.get_sheet_names() == ['release', 'b']
122+
assert wb.sheetnames == ['release', 'b']
123123
rows = list(wb['release'].rows)
124124
assert len(rows) == 3
125125
assert [ x.value for x in rows[0] ] == [ 'a' ]
@@ -152,7 +152,7 @@ def test_utf8(tmpdir):
152152

153153
# Check XLSX
154154
wb = openpyxl.load_workbook(tmpdir.join('release.xlsx').strpath)
155-
assert wb.get_sheet_names() == ['release']
155+
assert wb.sheetnames == ['release']
156156
rows = list(wb['release'].rows)
157157
assert len(rows) == 3
158158
assert [ x.value for x in rows[0] ] == [ 'é' ]

0 commit comments

Comments
 (0)