django-excel-storage
Django Excel Storage
Installation
pip install django-excel-storage
Usage
from django_excel_storage import ExcelStorage
def excelfunc():
objs = SomeModel.objects.all()
fpath = ExcelStorage(objs).save()
or
from django_excel_storage import ExcelStorage
def excelfunc():
data = [
{
'Column 1': 1,
'Column 2': 2,
},
{
'Column 1': 3,
'Column 2': 4,
}
]
fpath = ExcelStorage(data, 'my_data', font='name SimSum').save()
or
from django_excel_storage import ExcelStorage
def excelfunc():
data = [
['Column 1', 'Column 2'],
[1, 2],
[3, 4]
]
fpath = ExcelStorage(data, 'my_data', font='name SimSum').save()
or
from django_excel_storage import ExcelStorage
def excelfunc():
data = [
['Column 1', 'Column 2'],
[1, [2, 3]],
[3, 4]
]
fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='row_merge').save()
or
from django_excel_storage import ExcelStorage
def excelfunc():
headers = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5']
data = [['Value 1', [['Value 2 Row 1', [['Value 3', 'Value 4', [['Value 5']]]]], ['Value 2 Row 2', [['Value 3 Row 1', 'Value 4 Row 1', [['Value 5 Row 1']]], ['Value 3 Row 2', 'Value 4 Row 2', [['Value 5 Row 2']]]]]]]]
fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='list_row_merge', headers=headers)
or
from django_excel_storage import ExcelStorage
def excelfunc():
headers = ['Column 1', 'Column 2', 'Column 3', 'Column 4', 'Column 5']
mapping = {
'field_key': 'Column 1',
'data_key': 'Children 1',
'next': {
'field_key': 'Column 2',
'data_key': 'Children 2',
'next': {
'field_key': ['Column 3', 'Column 4'],
'data_key': 'Children 3',
'next': {
'field_key': 'Column 5',
}
}
}
}
data = [{
'Column 1': 'Value 1',
'Column 11': 'Value 11',
'Children 1': [{
'Column 2': 'Value 2 Row 1',
'Column 22': 'Value 22 Row 1',
'Children 2': [{
'Column 3': 'Value 3',
'Column 4': 'Value 4',
'Children 3': {
'Column 5': 'Value 5',
}
}]
}, {
'Column 2': 'Value 2 Row 2',
'Column 22': 'Value 22 Row 2',
'Children 2': [{
'Column 3': 'Value 3 Row 1',
'Column 4': 'Value 4 Row 1',
'Children 3': {
'Column 5': 'Value 5 Row 1',
}
}, {
'Column 3': 'Value 3 Row 2',
'Column 4': 'Value 4 Row 2',
'Children 3': {
'Column 5': 'Value 5 Row 2',
}
}]
}]
}]
fpath = ExcelStorage(data, 'my_data', font='name SimSum', merge_type='dict_row_merge', mapping=mapping, headers=headers)
Params
- font='name SimSum'
- Set Font as SimSum(宋体)
- force_csv=True
- CSV Format? True for Yes, False for No, Default is False
CSV
datas = [
[u'中文', ]
]
| Win Excel 2013 | Mac Excel 2011 | Mac Excel 2016 | Mac Numbers | |
|---|---|---|---|---|
| UTF8 | Messy | Messy | Messy | Normal |
| GB18030 | Normal | Normal | Normal | Messy |
| UTF8 + BOM_UTF8 | Normal | Messy | Normal | Normal |
| UTF16LE + BOM |
Metadata
Release files for django-excel-storage 2.0.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-excel-storage-2.0.11.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_excel_storage-2.0.11-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 9.4 kB
Release files / django-excel-storage-2.0.11.tar.gz
| Download URL | django-excel-storage-2.0.11.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04905499345c73995009af898d47f38efd89e156ecfc0a513f64b032fcd35deb
|
|
BLAKE2b-256 checksum How to use checksums |
98de5dff523894463cbff06a3fd853d8d41a49483cc5552c889b207d6c0bdb8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / django_excel_storage-2.0.11-py2.py3-none-any.whl
| Download URL | django_excel_storage-2.0.11-py2.py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
89a1da29bf609660f70eb412441babb6cd0da79c58cf00e20311ed1b722cff4f
|
|
BLAKE2b-256 checksum How to use checksums |
db34914e9452578377ba7bce901f8ef88868e94e77facf711a00c28a6f317a9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|