Skip to main content

xlreport – Easy Excel Export for Python objects

Project description

Xlreport – Easy Excel Export for Python objects

What it does

Xlreport is a wrapper around xlsxwriter that makes it super easy to dump your data into Excel files. It takes care of all the formatting, so you don't have to mess with xlsxwriter's details. Most of the time, you'll just use the to_file function to throw whatever data you've got into a nicely formatted spreadsheet. While Xlreport is mainly designed for 2D data (think tables with rows and columns), it can handle 1D data too. If you pass in a single-dimension list or array, it'll just fill up one column in your Excel file - simple as that.

#generate some random data
from numpy.random import default_rng
arr = default_rng(42).random((100, 4))


# Save data to an Excel file and immediately invoke the default application to open it (does not have to be ms excel)
import xlreport as xl
header = 'col1 col2 col3 col4'.split(' ') 
xl.to_file("test.xlsx", arr, header, title="Test numpy")

It is a useful tool for data inspection, as well as for simply creating reports. It is equally easy to create a file containing multiple sheets and links to them.

Multisheet file

Example of multisheet file. If we want to create a file containing multiple sheets, we can use the Exfile class. By default, the header cells are frozen to make it easier to browse multiple rows of data. (see: test_xlreport.py

import xlreport as xl

# get some diverse datasets for demonstration
data1 = get_packages()
data2 = generate_random_data(20)
data3 = [(x, y) for x, y in system_info().items()]
data3 = [(x, y) for x, y in system_info().items()]

# Construct and populate a multi-sheet Excel file
exfile = xl.Exfile("test_multisheet_file.xlsx")
exfile.write(data1, title="Current user packages")
exfile.write(data2, title="Random data")
exfile.write(data3, title="System Info", wrap=True)
exfile.add_links()
exfile.save(start=True)

Intelligent Column Sizing

Xlreport addresses common challenges associated with automatic column sizing in Excel. While xlsxwriter's worksheet.autofit() method can often produce undesirable results (e.g., excessively wide columns for long strings), Xlreport offers a pragmatic solution. Users can effectively control column widths by simply appending spaces to header strings, providing a straightforward method for layout optimization:

This means you don't have to manually calculate widths – just a few extra spaces, and your columns will look just right.

header = ["Normal column    ", "Description - longer column          "]

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

xlreport-0.0.4.tar.gz (35.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xlreport-0.0.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file xlreport-0.0.4.tar.gz.

File metadata

  • Download URL: xlreport-0.0.4.tar.gz
  • Upload date:
  • Size: 35.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for xlreport-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ba1184dd992d116f7ae4588241d816258f6c0662f237682acd8193083a1b2089
MD5 abddbbe0877edfa786cc85c112327348
BLAKE2b-256 a2514c48ad41dce51903e337cbc69cc8be070fc255f979263fbd581591daebf3

See more details on using hashes here.

File details

Details for the file xlreport-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: xlreport-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for xlreport-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 beac7ef7fe4388a77429fc77e3010f231a5a97028d31322faaf57f15e6fd751c
MD5 b5d36156830456fea8db721089e1466b
BLAKE2b-256 35f905433181e888f94905ee4a4bc966b69174724189ef6cd7490a7b0c8bdc05

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