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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.3.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.7

File hashes

Hashes for xlsxdocument-1.3.3.tar.gz
Algorithm Hash digest
SHA256 62b8fcccc403a6d234b4c3e701c628b9d4bd48c7dfba2874c881a430aab086de
MD5 159101518c599b8a8a26620c91f70272
BLAKE2b-256 1642b65c3c2f20e6802cb1672cd37d9c038baacb03cd43ab93a39601fe9b399c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.3 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.6.7

File hashes

Hashes for xlsxdocument-1.3.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ab460bf92db2f81eefb20419d0d546f4e57e3fd0c510eb40639bb9739a275184
MD5 d888ff2fb7c15904aa126b9f398f8436
BLAKE2b-256 8fc952507c9541f9f38de1416bd1d8866826478fbac012a056f3eddf34ffdf9f

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