Skip to content

Commit

Permalink
Fix #6 : AttributeError: module 'openpyxl.writer.excel' has no attrib…
Browse files Browse the repository at this point in the history
…ute 'save_virtual_workbook'
  • Loading branch information
G.Tjebbes committed Jun 2, 2023
1 parent d1c5f88 commit 1b78516
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sqla_inspect/ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def force_utf8(value):
:param str value:
:rtype: bytes
"""
return force_encoding(value, 'utf-8')
return force_encoding(value, "utf-8")


def force_encoding(value, encoding):
Expand Down
8 changes: 7 additions & 1 deletion sqla_inspect/excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,13 @@ def save_book(self, f_buf=None):
"""
if f_buf is None:
f_buf = io.BytesIO()
f_buf.write(openpyxl.writer.excel.save_virtual_workbook(self.book))

if hasattr(self.book, "save"):
self.book.save(f_buf)
# older versions of openpyxl
else:
f_buf.write(openpyxl.writer.excel.save_virtual_workbook(self.book))

f_buf.seek(0)
return f_buf

Expand Down

0 comments on commit 1b78516

Please sign in to comment.