Giter Site home page Giter Site logo

django-excel-response's Introduction

django-excel-response

Latest Version Test/build status Code coverage

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.

Installation

pip install django-excel-response

Provided Classes

  • excel_response.response.ExcelResponse

    Accepted arguments:

    • data - A queryset or list of lists from which to construct the output
    • output_filename - The filename which should be suggested in the http response, minus the file extension (default: excel_data)
    • worksheet_name - The name of the worksheet inside the spreadsheet into which the data will be inserted (default: None)
    • force_csv - A boolean stating whether to force CSV output (default: False)
    • header_font - The font to be applied to the header row of the spreadsheet; must be an instance of openpyxl.styles.Font (default: None)
    • data_font - The font to be applied to all data cells in the spreadsheet; must be an instance of openpyxl.styles.Font (default: None)
  • excel_response.views.ExcelMixin

  • excel_response.views.ExcelView

Examples

Function-based views

You can construct your data from a queryset.

from excel_response import ExcelResponse


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

Or you can construct your data manually.

from excel_response import ExcelResponse


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

Class-based views

These are as simple as import and go!

from excel_response import ExcelView


class ModelExportView(ExcelView):
    model = SomeModel

django-excel-response's People

Contributors

bertramr avatar broxeph avatar hussaintamboli avatar jwilhelm-godaddy avatar kmike avatar rmohan-godaddy avatar sociodroid avatar tarkatronic avatar

Watchers

 avatar

Forkers

lukaszb

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.