Skip to main content

Django Excel Storage

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-excel-storage-2.0.10.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

django_excel_storage-2.0.10-py2.py3-none-any.whl (4.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-excel-storage-2.0.10.tar.gz.

File metadata

  • Download URL: django-excel-storage-2.0.10.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for django-excel-storage-2.0.10.tar.gz
Algorithm Hash digest
SHA256 21e08ac46beb49cabdab3c6808b19d4c805924db0df075ff75cca9a50b2cdcfd
MD5 ffff9727a056e6bf7cf21fd52ed7da93
BLAKE2b-256 ecafe6fe5ffa7079ec399ad2b1e97a2baed89866fb972343ffebe69be3832a41

See more details on using hashes here.

File details

Details for the file django_excel_storage-2.0.10-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_excel_storage-2.0.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bb4d5d44c76bf25b7f4d98cfbbcb53c2640ddec37ece53914684582a784cf673
MD5 dbde1ffb8fcfeae764b4c55283b8d2d4
BLAKE2b-256 ff000872f381af84b1e2e307f59a23140ea697b3fbda7fc733c1639d6ba36b27

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page