Metadata-Version: 2.1
Name: excel-exporter
Version: 0.1.3
Summary: A Django library for exporting data.
Home-page: https://github.com/zhangyu836/django-excel-export
Author: Zhang Yu
Author-email: zhangyu836@gmail.com
License: BSD License
Keywords: django,Excel,xls,xlsx,spreadsheet,workbook,template
Platform: Any platform 
Description-Content-Type: text/markdown
Requires-Dist: xltpl (>=0.9.2)
Requires-Dist: pydocxtpl (>=0.2.1)
Requires-Dist: six


# django-excel-export

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

[Live Demo](https://tranquil-tundra-83829.herokuapp.com/)  
-  User: admin
-  Password: admin   

[Demo Source Code](https://github.com/zhangyu836/django-excel-export-demo)


## How to install

```sh
$ pip install excel-exporter
```


## How to use

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

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

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

```
![avatar](./images/person_export.png)

What you get

![avatar](./images/person_xlsx.png)

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

```python
# 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](./images/person_export2.png)

What you get
![avatar](./images/person_docx.png)

See [admin.py](https://github.com/zhangyu836/django-excel-export-demo/blob/main/demo/app/admin.py) in [Demo Source Code](https://github.com/zhangyu836/django-excel-export-demo).

