Skip to main content

Save pyexcel data with XlsxWriter, while retaining good formatting.

Project description

pyexcel-xlsxwx

Build Status PyPI version shields.io PyPI license PyPI pyversions

Save pyexcel data with XlsxWriter, while retaining good formatting.

Features

  • Allow setting column widths and word wrap.
  • A package for reading data is not included, please see pyexcel's plugins here.

Installation

$ pip install pyexcel-xlsxwx

Usage

>>> import pyexcel_xlsxwx
>>> data = OrderedDict() # from collections import OrderedDict
>>> data.update({"Sheet 1": [[1, 2, 3], [4, 5, 6]]})
>>> data.update({"Sheet 2": [["row 1", "row 2", "row 3"]]})
>>> pyexcel_xlsxwx.save_data("your_file.xlsx", data)

You can also define a custom config via:

>>> pyexcel_xlsxwx.save_data("your_file.xlsx", data, config=config)

Where config can be dictionary or path to YAML file.

The default YAML config is:

workbook:
  constant_memory: true
  strings_to_numbers: false
  strings_to_formulas: false
  strings_to_urls: true
worksheet:
  _default:
    freeze_panes: A2
#    column_width: 30
    smart_fit: true
    max_column_width: 30
format:
  _default:
    valign: top
    text_wrap: true

column_width can also accept a list and a dictionary where key indicates the column.

row_height can also be set the same way.

To cancel out freeze_panes, try:

>>> pyexcel_xlsxwx.save_data("your_file.xlsx", data, config={'worksheet': {'_default': {'freeze_panes': None}}})

The settings will merge (thanks to https://stackoverflow.com/questions/20656135/python-deep-merge-dictionary-data), so that the other formattings won't be lost.

Related projects

  • pyexcel-openpyxlx - export the styles for XlsxWriter.
  • pyexcel-export - operates using OpenPyXL, which seeming has bad word wrap support. However, the formatting can be well preserved.

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

pyexcel-xlsxwx-0.1.8.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

pyexcel_xlsxwx-0.1.8-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file pyexcel-xlsxwx-0.1.8.tar.gz.

File metadata

  • Download URL: pyexcel-xlsxwx-0.1.8.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.16.5-arch1-1

File hashes

Hashes for pyexcel-xlsxwx-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8e25b0f9447ca996bca07d4729142c451b956530bba231be2d66330b79addb0d
MD5 7aad5cc141874343fdf770d2379d5fb2
BLAKE2b-256 518b28f0d06f132d3d2cfe3f04501ed76e674ff9b9e892fb7819b248907d3fe0

See more details on using hashes here.

File details

Details for the file pyexcel_xlsxwx-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyexcel_xlsxwx-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.2 Linux/5.16.5-arch1-1

File hashes

Hashes for pyexcel_xlsxwx-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d8f5c08f3a92308e5c4f693d00b84c0814534cae46f10688d29ab471bff60d83
MD5 58abefd055c6ead5112c90c872cf0809
BLAKE2b-256 939d77cd0a90e6647d1f26fa91d3f4568329a4eea875572795357465cd7c59fa

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