Skip to main content

XLSXDocument

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: "https://example.com%s" % (
            instance.get_absolute_url(),
        ),
    )],
)

For lower-level control, use add_sheet() and table() directly to build sheets from arbitrary data:

xlsx = XLSXDocument()
xlsx.add_sheet("Sales")
xlsx.table(
    titles=["Product", "Quantity", "Price"],
    rows=[
        ["Widget A", 10, 9.99],
        ["Widget B", 5, 24.99],
    ],
)
return xlsx.to_response("sales.xlsx")

Strings starting with = are written as text, not as formulas, since exported data is often untrusted (formula injection). Wrap intentional formulas in Formula:

from xlsxdocument import Formula, XLSXDocument

xlsx.table(
    titles=["Product", "Quantity"],
    rows=[
        ["Widget A", 10],
        ["Widget B", 5],
        ["Total", Formula("=SUM(B2:B3)")],
    ],
)

You can also add multiple sheets to a single document:

xlsx = XLSXDocument()

xlsx.add_sheet("Orders")
xlsx.table(["ID", "Customer", "Total"], orders_data)

xlsx.add_sheet("Products")
xlsx.table(["SKU", "Name", "Stock"], products_data)

return xlsx.to_response("export.xlsx")

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

Metadata

Release files for xlsxdocument 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xlsxdocument 1.4.0
File Size Uploaded Provenance Actions
xlsxdocument-1.4.0.tar.gz 4.3 kB With provenance Details for xlsxdocument-1.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xlsxdocument 1.4.0
File Interpreter ABI Platform Actions
xlsxdocument-1.4.0-py3-none-any.whl Python 3 none any Details for xlsxdocument-1.4.0-py3-none-any.whl

Total release size: 9.1 kB

Release files / xlsxdocument-1.4.0.tar.gz

Download URL xlsxdocument-1.4.0.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
124f76171eb1fefc9726ed4dcf4960ab9bda74d83f5e781037edd44c67539322
BLAKE2b-256 checksum
How to use checksums
de4a5e9e9eade4c233814a185607d1893e90bb9e50b9d4d7bb0c264f561da3ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / xlsxdocument-1.4.0-py3-none-any.whl

Download URL xlsxdocument-1.4.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
483d8d3b884b742b21cd4d5d82e70fccb4d3fa161fa38220d8ace4e36d89a0ac
BLAKE2b-256 checksum
How to use checksums
a70fdc50d738cbbdac7e3bbc2cc130c587ca1b89a70ef3fb02ee43f55b9d21d2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for xlsxdocument 1.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for xlsxdocument-1.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page