Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

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. http://github.com/danpetrikin/django-excel-response/

Project Description

django-excel-response3

This is an overhaul of https://pypi.python.org/pypi/django-excel-response which was originally http://djangosnippets.org/snippets/1151/

  • added class detection for values, and will use the value str(class_value)
  • added support for floats, dollar strings, and comma separated number strings that were broken in other forks
  • refactored the code to resemble an actual class, as opposed to one giant init function
  • removed the performance killing import every time you write a sheet, xlwt is required. If you don’t like it use a CSV writer
  • refactored the CSV writing portion of the code to actually use python’s csv class
  • added width auto adjustment

Usage

from excel_response3 import ExcelResponse

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

or

from excel_response3 import ExcelResponse

def excelview(request):
    data = [
        ['Column 1', 'Column 2'],
        [1,2]
        [23,67]
    ]
    return ExcelResponse(data, 'my_data')

Constructor Kwargs

  • headers - an array containing column headers
  • output_name - maintaining this kwarg, but tries first to use the 2nd arg passed when defining the class
  • force_csv - forcibly respond with csv, defaults to False
  • encoding - defaults to ‘utf8’
  • sheet_name - defaults to ‘Sheet 1’
  • blanks_for_none - replace None values with ’’, defaults to True
  • auto_adjust_width - adjust width of each column automatically, defaults to True
Release History

Release History

This version
History Node

1.51

History Node

1.50

History Node

1.49

History Node

1.48

History Node

1.47

History Node

1.46

History Node

1.45

History Node

1.44

History Node

1.43

History Node

1.42

History Node

1.41

History Node

1.4

History Node

1.03

History Node

1.02

History Node

1.01

History Node

1.0

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-excel-response3-1.51.tar.gz (3.5 kB) Copy SHA256 Checksum SHA256 Source Jun 9, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting