Skip to main content

Common function when working with excel.

Project description

Django Excel Tools

https://badge.fury.io/py/django-excel-tools.svg https://travis-ci.org/NorakGithub/django-excel-tools.svg?branch=master

Common function when working with excel.

Requirements

Installations

Install django-excel-tools

pip install django-excel-tools

Usage

Class declaration

from django_excel_tools import serializers


class OrderExcelSerializer(serializers.ExcelSerializers):
    REGION_CHOICES = ('Central', 'North', 'East', 'West', 'South')
    product_name = serializers.CharField(max_length=100, verbose_name='Product Name')
    quantity = serializers.IntegerField(verbose_name='Quantity', blank=True, default=0)
    price = serializers.IntegerField(verbose_name='Price')
    region = serializers.CharField(max_length=10, verbose_name='Region', choices=REGION_CHOICES)
    transaction_date = serializers.DateField(date_format='%Y-%m-%d', date_format_verbose='YYYY-MM-DD',
                                             verbose_name='Transaction Date')

    class Meta:
        start_index = 1
        fields = ('product_name', 'quantity', 'price', 'region', 'transaction_date')

Class initialization

from openpyxl import load_workbook


def import_order():
    workbook = load_workbook(file)  # Create workbook from file. Used openpyxl
    worksheet = workbook.worksheets[0]
    serializer = OrderExcelSerializer(worksheet=worksheet, **kwargs)

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2017-08-22)

  • First release on PyPI.

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_tools-0.2.6.tar.gz (17.6 kB view details)

Uploaded Source

File details

Details for the file django_excel_tools-0.2.6.tar.gz.

File metadata

File hashes

Hashes for django_excel_tools-0.2.6.tar.gz
Algorithm Hash digest
SHA256 fa44ce84ccc06c043b4c93f6c92533c30e5a4aa898f85631a0d2da81d288ded2
MD5 9486de06757edc20cfe69fb842247717
BLAKE2b-256 cc5e6e26bcb7b33ddc3f96f79b54a00590ff429eddb8cee8c436a9954b3b7e51

See more details on using hashes here.

Supported by

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