Skip to main content

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


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.2.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

xlsxdocument-1.2.0-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file xlsxdocument-1.2.0.tar.gz.

File metadata

File hashes

Hashes for xlsxdocument-1.2.0.tar.gz
Algorithm Hash digest
SHA256 7e083160772050b97863257c4458aa607b0467278e1cf97f13e55d8cabb16477
MD5 91e37ccbdf9481afb094459c6b3c2968
BLAKE2b-256 3b471a6bfc487c2437ec016c8cd7fd14721a736c587de3778120027f7a358eb0

See more details on using hashes here.

File details

Details for the file xlsxdocument-1.2.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for xlsxdocument-1.2.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ed8972b3627bffedd6a049ec67c8592bdc2d8c3c23c769501e412db0ed604dff
MD5 dad891b145fdf690f982ea2fb7a9b865
BLAKE2b-256 e6a86e92b68dc1c7cdf3b3988eb51b91a3e0868ba3ab082ed4682551f4938d4f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page