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

Uploaded Source

Built Distribution

xlsxdocument-1.3.0-py2.py3-none-any.whl (4.6 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for xlsxdocument-1.3.0.tar.gz
Algorithm Hash digest
SHA256 c0ffa1f9c201fe8eea255b91b0713787c5f2f352325205cb737e63fd4560fb55
MD5 249fd6fce53bc94db38ba7875f4d0de4
BLAKE2b-256 e4af5f25b4de7f0be8230f97ead05f86d713de090d6f721b63b2bc5fa52280fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsxdocument-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 d61d45766c3e76e11eac3c14b3b76210834ef65800a65f59564200be11b923ee
MD5 df46b0fb8d9f0c15a2b2bcd3cdd6c85d
BLAKE2b-256 2835ed0a50210862cf73f4bf3f4c63af80c71b20d1dfab2c06fd5d51f9b02bef

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