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.8.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for xlsxdocument-1.3.8-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa128ca8469bfe5dbb9ba8b6594a8a45a28bc9093e72a15ac581ba6c6682e5a1 |
|
MD5 | 92f69a5e3c4da093ebd983ac62466616 |
|
BLAKE2b-256 | 0b654816ca650f720397e5f0e40c98f9855127c1afa77d26c2293239dc2dcc7f |