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 gettext_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.5.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file xlsxdocument-1.3.5.tar.gz
.
File metadata
- Download URL: xlsxdocument-1.3.5.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d8189e91870e64c65fd734d3dfd0b5c1d45adedc3b3bb5c162864d3a3b542b4 |
|
MD5 | ac1a3c78341bb2099c231693fab3e954 |
|
BLAKE2b-256 | 722c6e196ab42777875badd5838f0ebc5480d183ca615757f09c15ccc54087c5 |
File details
Details for the file xlsxdocument-1.3.5-py2.py3-none-any.whl
.
File metadata
- Download URL: xlsxdocument-1.3.5-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.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b41ff91d599449d265ebe2ae3d927d41cb4f23bd27a208c645fafc6b42fe76a5 |
|
MD5 | e421b734ab70f0f6cccc616631065d05 |
|
BLAKE2b-256 | 6eb779dbdd46e1083f69e88dd03462b2c15b3e08519958bce8431887b56cd361 |