XlsxWriter object save as http response to create download in Django

A little update on @alecxe response for Python 3 (io.BytesIO instead of StringIO.StringIO) and Django >= 1.5 (content_type instead of mimetype), with the fully in-memory file assembly that has since been implemented by @jmcnamara ({‘in_memory’: True}) ! Here is the full example : import io from django.http.response import HttpResponse from xlsxwriter.workbook import Workbook def your_view(request): … Read more

Setting styles in Openpyxl

As of openpyxl version 1.5.7, I have successfully applied the following worksheet style options… from openpyxl.reader.excel import load_workbook from openpyxl.workbook import Workbook from openpyxl.styles import Color, Fill from openpyxl.cell import Cell # Load the workbook… book = load_workbook(‘foo.xlsx’) # define ws here, in this case I pick the first worksheet in the workbook… # NOTE: … Read more

Using openpyxl to read file from memory

In the docs for load_workbook it says: #:param filename: the path to open or a file-like object ..so it was capable of it all the time. It reads a path or takes a file-like object. I only had to convert my file-like object returned by urlopen, to a bytestream with: from io import BytesIO wb … Read more