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.0.tar.gz
(3.5 kB
view details)
Built Distribution
File details
Details for the file xlsxdocument-1.3.0.tar.gz
.
File metadata
- Download URL: xlsxdocument-1.3.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ffa1f9c201fe8eea255b91b0713787c5f2f352325205cb737e63fd4560fb55 |
|
MD5 | 249fd6fce53bc94db38ba7875f4d0de4 |
|
BLAKE2b-256 | e4af5f25b4de7f0be8230f97ead05f86d713de090d6f721b63b2bc5fa52280fd |
File details
Details for the file xlsxdocument-1.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: xlsxdocument-1.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d61d45766c3e76e11eac3c14b3b76210834ef65800a65f59564200be11b923ee |
|
MD5 | df46b0fb8d9f0c15a2b2bcd3cdd6c85d |
|
BLAKE2b-256 | 2835ed0a50210862cf73f4bf3f4c63af80c71b20d1dfab2c06fd5d51f9b02bef |