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.
Screenshots
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xlreport-0.0.2.tar.gz.
File metadata
- Download URL: xlreport-0.0.2.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecd6fe8a36cd9310d493a2ec79236c927532d99c02851a77e594722bc6abf2bc
|
|
| MD5 |
16bfe0f73b2496a7b72f27dbfb0f146d
|
|
| BLAKE2b-256 |
842bd8b111c0d7dd340b6fbcf4a1febd1ad640544fb8d5872b04e03b99d3c355
|
File details
Details for the file xlreport-0.0.2-py3-none-any.whl.
File metadata
- Download URL: xlreport-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb84d22b66bb41bf6a66e03288e2f63a9bfbe004ab6c2f0f9e057e5de50bd24
|
|
| MD5 |
d4bea6c38a5b4edf6f5d266af6188628
|
|
| BLAKE2b-256 |
28e60f1f9c316577ebff22b9893b24fbd67a2e8f60691d8e0b76d5add7d50278
|