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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.7.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/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5

File hashes

Hashes for xlsxdocument-1.3.7.tar.gz
Algorithm Hash digest
SHA256 7a8f309a2e5ef540a9070adb7eba3632087ce25d7321a32cad16b36db30dc27a
MD5 0ace77cc6de305b19bf9ce64d8c8b8e0
BLAKE2b-256 d48f35dde5d0363c3a7c0b7b70bfe9c73068ac3aaeaf42abe4e2ccadfaa8b736

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.7-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/51.1.0.post20201221 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.5

File hashes

Hashes for xlsxdocument-1.3.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2ee10e403c52f909d0856f541e18eccdb672c39ab2490e201e678621ab97cc02
MD5 5ec52c2075ddd1338b52c3d4429ba488
BLAKE2b-256 32687a323fc584068fa463d66f6efee4b2d13112e30476a287e4c7695c7b0e5f

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