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.4.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file xlsxdocument-1.3.4.tar.gz
.
File metadata
- Download URL: xlsxdocument-1.3.4.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea1b7c5f82a542441a63b4ec8d86044fc5b27baa42fd9eb4a7d2bbe1d2be35ef |
|
MD5 | bc17a142ea77b56baa0364095043991b |
|
BLAKE2b-256 | 5a4bd600ae3a96bbe68e7d4ae75955d66f5898423c712759da01ed4493c450ea |
File details
Details for the file xlsxdocument-1.3.4-py2.py3-none-any.whl
.
File metadata
- Download URL: xlsxdocument-1.3.4-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.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7d649b8d27cbe483be5d29c7f8a7774ff39c26b35e913c40c35c7da4129ec69 |
|
MD5 | 47b94425c018ccf97520f8ebe7c2634d |
|
BLAKE2b-256 | 625ba186ee2e38fd114837bb655a636b84a4852364aebf340c2362bd29a987fe |