Django package to easily render Excel spreadsheets
Project description
A subclass of HttpResponse which will transform a QuerySet, or sequence of sequences, into either an Excel spreadsheet or CSV file formatted for Excel, depending on the amount of data.
Installation
pip install django-excel-response
Provided Classes
excel_response.response.ExcelResponse
Accepted arguments:
data - A queryset or list of lists from which to construct the output
output_filename - The filename which should be suggested in the http response, minus the file extension (default: excel_data)
worksheet_name - The name of the worksheet inside the spreadsheet into which the data will be inserted (default: None)
force_csv - A boolean stating whether to force CSV output (default: False)
header_font - The font to be applied to the header row of the spreadsheet; must be an instance of openpyxl.styles.Font (default: None)
data_font - The font to be applied to all data cells in the spreadsheet; must be an instance of openpyxl.styles.Font (default: None)
excel_response.views.ExcelMixin
excel_response.views.ExcelView
Examples
Function-based views
You can construct your data from a queryset.
from excel_response import ExcelResponse
def excelview(request):
objs = SomeModel.objects.all()
return ExcelResponse(objs)
Or you can construct your data manually.
from excel_response import ExcelResponse
def excelview(request):
data = [
['Column 1', 'Column 2'],
[1,2]
[23,67]
]
return ExcelResponse(data, 'my_data')
Class-based views
These are as simple as import and go!
from excel_response import ExcelView
class ModelExportView(ExcelView):
model = SomeModel
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-excel-response-2.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20f9565f6dcc3b5b22a5e0a498db0139db606e3211675e8ffe1bfda18f7464db |
|
MD5 | d723ffb5d1bbc34c1568caf45ca0d684 |
|
BLAKE2b-256 | 0f7f80354492c62258069ea3cdde708de3cb7e323810c9d885bc51de3d350fef |
Hashes for django_excel_response-2.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe8e637166b224f44313823a21bca0f5724cccac93966dac68ea0f1b7712f390 |
|
MD5 | 656c92a77b1c205b69b8f05d7a41510d |
|
BLAKE2b-256 | 2db383760295f1cc9005965072ae6acea3f3592d5e64013658a64789990f03d6 |