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.9.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file xlsxdocument-1.3.9.tar.gz
.
File metadata
- Download URL: xlsxdocument-1.3.9.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eab8732a681ae1dff3fc401022e25069666075a4fc6109d60724822385d5f526 |
|
MD5 | 3b9074852884996b45d1b7667b30954e |
|
BLAKE2b-256 | c168d7a4fc16de8c0a54dc5309fe2f4141d27506206737f4f75356a123ba19b2 |
File details
Details for the file xlsxdocument-1.3.9-py2.py3-none-any.whl
.
File metadata
- Download URL: xlsxdocument-1.3.9-py2.py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdf7518607d33316d432e9da08173661fb42a76d746343805c740afe220678c4 |
|
MD5 | 83268903e32e9c7b059fd1e927ac09d7 |
|
BLAKE2b-256 | 4a46303053793f845bf9b4e2de7a7208aea925ba40d1fdb0ee6ce1ad9132fa5e |