Skip to main content

A function extends of Tarken's django-excel-response

Project description

django-excel-response

A subclass of HttpResponse which will transform a QuerySet, or sequence of sequences, into either an Excel spreadsheet or CSV file formatted for Excel, depending on the amount of data. All of this is done in-memory and on-the-fly, with no disk writes, thanks to the StringIO library.

django-excel-response2

When using Tarken’s django-excel-response. We find that Chinese is messed code when we open .xls in Mac OS. As discussed in http://segmentfault.com/q/1010000000095546. We realize django-excel-response2 Based on Tarken’s django-excel-response to solve this problem By adding a Param named font to set font.

At The Same Time:

  • Fix Bug
    • can’t subtract offset-naive and offset-aware datetimes

Installation

pip install django-excel-response2

Usage

from excel_response2 import ExcelResponse

def excelview(request):
    objs = SomeModel.objects.all()
    return ExcelResponse(objs)

or:

from excel_response2 import ExcelResponse

def excelview(request):
    data = [
        ['Column 1', 'Column 2'],
        [1, 2],
        [3, 4]
    ]
    return ExcelResponse(data, 'my_data', font='name SimSum')

Params

  • font=’name SimSum’
    • Set Font as SimSum(宋体)

  • force_csv=True
    • CSV Format? True for Yes, False for No, Default is False

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-response2-2.0.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

django_excel_response2-2.0.0-py2.7.egg (5.0 kB view details)

Uploaded Source

File details

Details for the file django-excel-response2-2.0.0.tar.gz.

File metadata

File hashes

Hashes for django-excel-response2-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b15d9b1979970f449bab77898991424ef638f571dd9085aaf1dfc084d0c2333e
MD5 5fc8582f7c90840268be4a7e5a0f64dd
BLAKE2b-256 71c32b5d4f270e389f5ec739de2193398acfc77a464861795a4b9f6aa591d587

See more details on using hashes here.

File details

Details for the file django_excel_response2-2.0.0-py2.7.egg.

File metadata

File hashes

Hashes for django_excel_response2-2.0.0-py2.7.egg
Algorithm Hash digest
SHA256 42ba8370cb794145dc5c4b804cfca3b66f9c0977803c7a61150942738b1ebc09
MD5 3ada8a8918a4f6d8136f6bd14f26f6b4
BLAKE2b-256 c345e351364cc910f85298e3915d2d04cdb3e31adfad0299b01ad2db494101f6

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