Skip to main content

Save a list as an Excel file easily.

Project description

save_as_xlsx

PyPI - Version PyPI - Python Version


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

save_as_xlsx-0.2.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

save_as_xlsx-0.2.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file save_as_xlsx-0.2.1.tar.gz.

File metadata

  • Download URL: save_as_xlsx-0.2.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.14.0 HTTPX/0.28.1

File hashes

Hashes for save_as_xlsx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 577c763e6baee32e7b404526e32a40caaf71fe3586c7fdba4437df72497e12ea
MD5 96c8b968dd2ac943b9cb05c0f42875f3
BLAKE2b-256 6bfd09f240d9884b7a83d9dd9f73414ef23da1788f17337ddf8cdb25dd5980da

See more details on using hashes here.

File details

Details for the file save_as_xlsx-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: save_as_xlsx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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

Hashes for save_as_xlsx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4910454f195772dcbf78f220646badd5ef5aca9f9e68dfc819a61f7b4124181f
MD5 5fdf68eb93c9e671b4b1d7efeda02849
BLAKE2b-256 ebea1425e8510448a6e4908eee782ad13771069eb7a519afd93cfa45578a1e13

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