Saving openpyxl file via text and filestream

前端 未结 5 1127
清酒与你
清酒与你 2021-02-01 16:49

I\'m building OpenPyXL into an application that expects a string containing the content of the excel file, for it to write via file stream.

From my investigation into th

5条回答
  •  别那么骄傲
    2021-02-01 17:28

    jcollado's answer is actually valid, but there is also a function (sadly not documented yet) called "save_virtual_workbook" in openpyxl.writer.excel that will take your workbook and return the workbook as a string:

    from openpyxl.workbook import Workbook
    from openpyxl.writer.excel import save_virtual_workbook
    
    wb = Workbook()
    print save_virtual_workbook(wb)
    

    What you're looking for is the string returned by save_virtual_workbook()

提交回复
热议问题