--- id: drf-excel version: "2.6.0" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # drf-excel — Django REST Framework renderer for Excel spreadsheet (xlsx) files. License: permissive · Maintenance: active · Downloads: 150.7K/mo ## 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 above — 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 pip install drf-excel uv add drf-excel 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_current - Install friction: low - Maintenance: active - Downloads: 150.7K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags django rest framework excel export, xlsx renderer drf, export api data to excel, django spreadsheet renderer, openpyxl django rest, rest api excel output, drf xlsx export, django-rest-framework, excel-export, data-serialization [View on SkillFed](https://skillfed.io/packages/drf-excel) · [View on PyPI](https://pypi.org/project/drf-excel/)