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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: xlsxdocument-1.3.10.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for xlsxdocument-1.3.10.tar.gz
Algorithm Hash digest
SHA256 f09471b18cea78b0e2c4fd84e21f3dcd95a6ca7ae3815395e17517467ae89122
MD5 4eb0b6b0c7b62f4f54f12ca705461eb0
BLAKE2b-256 c6329ac4caeaf324ba6d75e7b2e06813c9fbc0882b8b52b2e505cf5d13274944

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xlsxdocument-1.3.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e7762f6d643854a054c02d7732b9d9c0df81bfe11e12931323e2d14dafc69034
MD5 6dce5d100f41db10eda5bb2d1123c161
BLAKE2b-256 4fd2f11bab89d2ed37686a8e98cccfca1b72d12b1f15fcc3b0f03db812271c79

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