Save a list as an Excel file easily.
Project description
save_as_xlsx
Table of Contents
About
If you have some tabular data, this package gives you a trivial one-line way of saving it as an Excel (.xlsx) file. The data will be saved formatted as a Table (with a header row, filtering, sorting and nice formatting).
Just pass any iterable (list, tuple, generator...) of:
- dictionaries
- dataclasses
- Pydantic model instances
Nesting of complex data types is handled.
Enums are saved as the enum member name.
Uses the xlsxwrite package to do the actual writing.
Installation
pip install save-as-xlsx
Usage
from save_as_xlsx import SaveAsXlsx
DATA = [
{"a": 1, "b": "qwe"},
{"b": "asd", "c": True},
]
# simplest case
SaveAsXlsx(DATA, "file.xlsx", auto_save=True)
# or if you want to customize the XLSX file before saving:
with SaveAsXlsx(DATA, "file.xlsx") as saver:
# do something with saver.workbook or saver.worksheet (see xlsxwriter)
pass
# the data can be any iterable - tuple, generator...
SaveAsXlsx(({"num": i} for i in range(5)), "file.xlsx", auto_save=True)
# file name can be a Path
from pathlib import Path
SaveAsXlsx(DATA, Path("file.xlsx"), auto_save=True)
# saved columns: a, b, c
# you can specify the order of columns - these will be first, remaining ones after them
SaveAsXlsx(DATA, "file.xlsx", column_order=("b", "c"))
# saved columns: b, c, a
# or maybe you just want some of the columns, and an empty one
SaveAsXlsx(DATA, "file.xlsx", column_order=("b", "empty"), extra_columns=False)
# saved columns: b, empty
License
save-as-xlsx is distributed under the terms of the MIT license.
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 save_as_xlsx-0.1.0.tar.gz.
File metadata
- Download URL: save_as_xlsx-0.1.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
608e9c4d0531b762e00940203b2aa59e5ea550fa6260204015aa467e5cd177e5
|
|
| MD5 |
7e737c4b41fda64b7317593e34caf12b
|
|
| BLAKE2b-256 |
4eb88322d93bad24d19b2ce374627b0b9f26a422b4bab5d8a58f28f32b81ff4a
|
File details
Details for the file save_as_xlsx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: save_as_xlsx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.14.0 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
63dc6ee71be8d340531a90b3d638a276397baded5edf8299920de41bf80986dd
|
|
| MD5 |
d87d1a36d5ba683ce462c6f961391d13
|
|
| BLAKE2b-256 |
9fdb9457c9df7a7385bf04f6266e63f35f923ea48b1fc73159d17bbbcb0a5dc2
|