Saving openpyxl file via text and filestream

前端 未结 5 1134
清酒与你
清酒与你 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:10

    What about using a StringIO object to save the contents of the file:

    from openpyxl.workbook import Workbook
    from StringIO import StringIO
    
    output = StringIO()
    wb = Workbook()
    wb.save(output)
    print output.getvalue()
    

    The string you're looking for is what is being printed in the last line of this example.

提交回复
热议问题