Writing an excel worksheet into a BytesIO object

Viewed 21

I am trying to store a openpyxl worksheet into a BytesIO object, but failing miserably. Please find my methodology below.

I have defined the following BytesIO object

import io
io_buffer = io.BytesIO()

I am trying to read an excel workbook with openpyxl using

from openpyxl import Workbook, load_workbook
workbook = load_workbook("path to the file") # Your Excel file

and then read a specific sheet from that workbook by using

ws = workbook['sheetname']

But then, how do i store the "ws" object into "io_buffer" as bytes? Can someone help me with this please?

0 Answers
Related