Easily create XLSX documents with Django
Project description
This is a wrapper for openpyxl which makes creating XLSX documents with the purpose of exporting data less boring:
from xlsxdocument import XLSXDocument def xlsx_export(request): some_data = Bla.objects.all() xlsx = XLSXDocument() xlsx.table_from_queryset(Bla.objects.all()) return xlsx.to_response('bla.xlsx')
Adding in additional cells at the end is also possible:
xlsx = XLSXDocument() xlsx.table_from_queryset( Bla.objects.all(), additional=[( 'Full URL', lambda instance: 'http://example.com%s' % ( instance.get_absolute_url(), ), )], )
You can also easily add the facility to export rows to Django’s administration interface:
from django.contrib import admin from django.utils.translation import ugettext_lazy as _ from xlsxdocument import export_selected from app import models class AttendanceAdmin(admin.ModelAdmin): list_filter = ('event',) actions = (export_selected,) admin.site.register(models.Event) admin.site.register(models.Attendance, AttendanceAdmin)
If you require additional columns with export_selected use this snippet instead:
from xlsxdocument import create_export_selected class AttendanceAdmin(...): actions = [ create_export_selected( additional=[ # ... see above ] ) ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
xlsxdocument-1.3.2.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file xlsxdocument-1.3.2.tar.gz
.
File metadata
- Download URL: xlsxdocument-1.3.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d84c3620e143a2732d5c19fbf808e9aef723ab6b9bc1e034180f2f7f3360f2da |
|
MD5 | cf40c8c74b9506226cc28962a4616d60 |
|
BLAKE2b-256 | f490fba53c4f159bc076bbb797f0c76b0cbd28201d3236311c707fe54ada55d7 |
File details
Details for the file xlsxdocument-1.3.2-py2.py3-none-any.whl
.
File metadata
- Download URL: xlsxdocument-1.3.2-py2.py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e152517a2cc6b4244a36fc61ef66a0442f974b235e1ad3347e2f256faff7243 |
|
MD5 | b3835805deaf9f6729341b95d2ca05d3 |
|
BLAKE2b-256 | a482fc9108275f157c96dee2d425631aae9c75f338110c5f52dc6a2cd863b2c6 |