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

Uploaded Source

Built Distribution

xlsxdocument-1.3.6-py2.py3-none-any.whl (4.0 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.6.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5

File hashes

Hashes for xlsxdocument-1.3.6.tar.gz
Algorithm Hash digest
SHA256 fc927b9f8a2779537a7639bd5f0e700622ff9c7ed0edb58ab4acdd48533ca9e8
MD5 75debd7382c2a73d58f78e8991864d07
BLAKE2b-256 ee4f2512922eda6c95e0c54b64b73ccbfcbac44a2e80dd33868fe8cfe309c736

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.6-py2.py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.5

File hashes

Hashes for xlsxdocument-1.3.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4eefe4856b349fef71e18ba80ee0aeecfc612d2a3122fa2aca3d859e2825c16b
MD5 ffd0ef07a558aa1a0188c6041a1f87b6
BLAKE2b-256 2dce8bac83452b869c8b92fa3bdd58afb07808ae3336d3b3e1509b4c1d20290c

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