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 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


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 details)

Uploaded Source

Built Distribution

xlsxdocument-1.3.8-py2.py3-none-any.whl (4.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.8.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for xlsxdocument-1.3.8.tar.gz
Algorithm Hash digest
SHA256 abd4aaea3c8e433831c5f5eeea06c97c7374559c9e0c679b465c01a55c79ac84
MD5 567afde53d5aca5ff152d589b681326a
BLAKE2b-256 e525361d8ef823c301a9f3079f6bda121dc5eaa5d104ad06520181fd472df5a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.8-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for xlsxdocument-1.3.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aa128ca8469bfe5dbb9ba8b6594a8a45a28bc9093e72a15ac581ba6c6682e5a1
MD5 92f69a5e3c4da093ebd983ac62466616
BLAKE2b-256 0b654816ca650f720397e5f0e40c98f9855127c1afa77d26c2293239dc2dcc7f

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