Skip to content

A Django library for exporting data in xlsx, xls, docx format.

License

Notifications You must be signed in to change notification settings

zhangyu836/django-excel-export

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-excel-export

A Django library for exporting data in xlsx, xls, docx format.

Live Demo

  • User: admin
  • Password: admin

Demo Source Code

How to install

$ pip install excel-exporter

How to use

Export is achieved by subclassing ExportAdmin, which implements export as an admin action.

# app/admin.py
from excel_exporter.admin import ExportAdmin

class PersonAdmin(ExportAdmin):
    list_display = ( 'name', 'address', ...)
    export_fields = ('name', 'address', ...)
    

avatar

What you get

avatar

You can define custom export action and add it to export_actions list:

# app/admin.py
from excel_exporter.admin import ExportAdmin
from excel_exporter.action import Docx
class PersonExportDocx(Docx):
    desc = 'persons to docx'
    tpl = 'persons.docx'
    queryset_name = 'ps'

    def get_payloads(self, queryset, list_display):
        payload = super().get_payloads(queryset, list_display)
        payload['test'] = 'A Big Company'
        payload['logo'] = 'staticfiles/1.jpg'
        return payload

class PersonaAdmin(ExportAdmin):
    list_display = ( 'name', 'address', ...)
    export_actions = [PersonExportDocx, ...] 

    

avatar

What you get avatar

See admin.py in Demo Source Code.

About

A Django library for exporting data in xlsx, xls, docx format.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages