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.3.tar.gz (12.4 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.3-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for xlreport-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0e575ac71e458dbe2d6060def785d64e1ad6d805c70b7266725d9d48dd0a1d40
MD5 17fe779f762a734345b302d32e83603c
BLAKE2b-256 f46276199ed897c491b5e1abaeb7b34fc8930d3ce2cc3444437a4d996bba493b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for xlreport-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8785d8ced4ed21ddd85de3691470b42a62044c7080f11b0934082b5a9e38bf8e
MD5 65327bb9004e64a65211dfce2c8a24dc
BLAKE2b-256 ed828ddf0a2356038ae2adf2c4609a1ea457cbc61517e8daa1b593db5727857d

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