Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

django_excel_templates

Django MS Excel Generator aims to create a template system for generation of the Excel documents for views (instead of HTML).

  1. Simple case: sniff model and make an excel table;

  2. Medium case: sniff model, make excel table, and apply predetermined styles (fonts, colors, layout)

  3. Advanced case: take models and set custom styles or modify existing

Requiments

Install

You have two options:

  1. Easy_insall with install the package and all dependencies if they aren’t already installed into your lib/python/:

    easy_install django_excel_templates
  2. Download and untar the package; run:

    python setup.py install

Examples

testobj in the following examples is django.db.models.query.QuerySet instance

Simple: create ExcelReport instance, add excel sheet, add queryset to analyze:

>>> from django_excel_templates import *
>>> report = ExcelReport()
>>> report.addSheet("TestBasic")
>>> report.addQuerySet(testobj, REPORT_HORZ, addheader=True)

Medium (create styles, one by one): create ExcelStyle instance to specify style (see help(ExcelStyle) for available methods and style options), create ExcelFormatter instance, add style to it:

>>> report.addSheet("TestStyle")
>>> style = ExcelStyle()
>>> style.set_alignment(horz=3, wrap=1)
>>> style.set_font(font_color='000000', bold=True, italic=True)
>>> style.set_border(border_color='000000', border_style=5)
>>> style.set_pattern(pattern_color='339933', pattern=1)
>>> formatter = ExcelFormatter()
>>> formatter.addBodyStyle(style=style)
>>> report.addFormatter(formatter)
>>> report.addQuerySet(testobj, orientation=REPORT_HORZ, addheader=True)

Medium (create styles all at once):

>>> report.addSheet("TestStyle2")
>>> headerstyle = ExcelStyle(font_color='00FF00', shadow=True, underline=True,
                             pattern_color='000000', pattern=1, border_style=5,
                             border_color='FFFFFF')
>>> col_style = ExcelStyle(font_color='FFFFFF')
>>> formatter.addHeaderStyle(headerstyle)
>>> formatter.addColunmStyle('column_name', style=col_style)
>>> report.addQuerySet(testobj, REPORT_HORZ, True)

Advanced: change existing styles, set custom styles, adjust column style and width:

>>> report.addSheet("ModifyStyle")
>>> style.set_font(font_color='000000', bold=False, underline=True)
>>> style.set_border(border_color='330099', border_style=6)
>>> style.set_pattern(pattern_color='FFFFFF', pattern=1)
>>> colstyle.set_pattern(pattern_color='FFFF33', pattern=1)
>>> formatter.setWidth('column1_name, column2_name', width=600)
>>> report.addQuerySet(testobj, REPORT_HORZ, True)

To make django.http.HttpResponse out of report and tell the broswer to treat it as an excel attachment:

>>> response = HttpResponse(report.writeReport(), mimetype='application/ms-excel')
>>> response['Content-Disposition'] = 'attachment; filename=foo.xls'

Metadata

Release files for django_excel_templates 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for django_excel_templates 0.1
File Size Uploaded
django_excel_templates-0.1.tar.gz 12.8 kB Details

Release files / django_excel_templates-0.1.tar.gz

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL django_excel_templates-0.1.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b6d804df960351a6da5f0c9040b9cdf9e22c95490d3d23e81803ffa2a48be7e6
BLAKE2b-256 checksum
How to use checksums
49504d10dfd431c46a0223b84550a630d3e156aadfdb3253771f46b4abb081e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page