skillfed

drf-excel

Django REST Framework renderer for Excel spreadsheet (xlsx) files.

drf-excel v2.6.0 150.7K downloads/30d#10,959 on PyPI240
Permissive license BSD-3-Clause Active released

What it is and what it does

drf-excel is a Django REST Framework renderer that converts API responses into Excel spreadsheets (.xlsx files). It integrates with DRF's standard renderer pipeline, allowing views to serve Excel exports alongside JSON and other formats. The package uses OpenPyXL to build the spreadsheets and provides a mixin (XLSXFileMixin) to handle HTTP headers and filename configuration.

The package supports extensive styling of headers, column headers, body rows, and individual columns through view attributes or dynamic methods. It can apply fonts, colors, borders, alignment, and number formats to cells. Additional features include auto-filtering on header rows, per-column styling overrides, sheet view options (like right-to-left layout), and the ability to use serializer field labels as column headers instead of field names.

Use it for:

  • Export REST API query results to Excel for business reporting and data analysis workflows
  • Generate styled Excel reports with custom headers, logos, and formatted data cells from API endpoints
  • Provide end users with downloadable spreadsheets of filtered or paginated API data with proper filenames
  • Create multi-column exports with per-column number formatting (dates, currency, scientific notation) from serialized data
  • Build data export features that respect API permissions and serializer field definitions automatically

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Adds an Excel spreadsheet (xlsx) renderer to Django REST Framework, allowing API views to export data directly as formatted Excel files using OpenPyXL.

Yes. drf-excel is actively maintained, has low install friction, carries a permissive license, and solves a common need for Django REST Framework users. It integrates cleanly into DRF's renderer architecture and supports modern Python versions (3.10–3.14) and current Django releases. No known vulnerabilities. Install it if you need to export API data to Excel.

Install

drf-excel on PyPI

pip

pip install drf-excel

uv

uv add drf-excel

poetry

poetry add drf-excel

Installing drf-excel

Before you install

Low friction install with just two runtime dependencies (djangorestframework and openpyxl). Active maintenance with a release 8 days ago and 240 repository stars indicate ongoing support.

License in practice

BSD-3-Clause permissive license allows use in commercial and proprietary projects with minimal restrictions; attribution required.

Quickstart

pip install drf-excel

# In settings.py REST_FRAMEWORK config:
REST_FRAMEWORK = {
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'drf_excel.renderers.XLSXRenderer',
    ),
}

# In views.py:
from drf_excel.mixins import XLSXFileMixin
from drf_excel.renderers import XLSXRenderer

class MyViewSet(XLSXFileMixin, ReadOnlyModelViewSet):
    renderer_classes = (XLSXRenderer,)
    filename = 'export.xlsx'

Requires Django REST Framework >= 3.14 and OpenPyXL >= 2.4; Python >= 3.10.

Verify before relying

  • Whether column-level formatting (fonts, borders, fills) works correctly with all OpenPyXL versions >= 2.4
  • Performance characteristics when exporting large datasets (row count thresholds)
  • Compatibility with custom pagination classes beyond the documented None requirement

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — djangorestframework, openpyxl
Maintenance actively maintained — 8 days since the last release
Last repo commit
First released
Downloads 150,715/month — #10,959 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: drf_excel-2.6.0-py3-none-any.whl

Keywords: djangorestframework, django rest framework, excel, spreadsheet, rest, restful, api, xls, xlsx, openpyxl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 5.2Framework :: Django :: 6.0Framework :: Django :: 6.1Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Dynamic Content

Tags

django rest framework excel exportxlsx renderer drfexport api data to exceldjango spreadsheet rendereropenpyxl django restrest api excel outputdrf xlsx export
django-rest-frameworkexcel-exportdata-serialization

More WWW/HTTP packages