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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for xlsxdocument-1.3.1.tar.gz
Algorithm Hash digest
SHA256 b95f3a937ddd12dc700bea1d57760dfdf215774c26d44f37966f2d0977b2240d
MD5 0c77bf3d33077e7dc8781f39c01eaabb
BLAKE2b-256 4057866a20ffc5b4bdb5be8d3699b5151be3007cadb82c68f43b534a27778959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsxdocument-1.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 33fc8cf8e8d9b3f9b897847b627b30c5c2f8108f0fade3599a2789eec23ac4e3
MD5 4a9ff1348413afaea8499a1499528699
BLAKE2b-256 1196e9f4494f2c1fe4944400856882886d48cf5f5e612da9149c253fb12a5787

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