Skip to main content

Wrapper around xlsxwriter to improve usability

Project description

Excelipy

codecov

Installation

You can install the package using pip:

pip install excelipy

Usage

The idea for this package is for it to be a declarative way of using the xlsxwritter. It allows you to define Excel files using Python objects, which can be more intuitive and easier to manage than writing raw Excel files.

Simple Example

import excelipy as ep

sheets = [
    ep.Sheet(
        name="Hello!",
        components=[
            ep.Text(text="Hello world!", width=2),
            ep.Fill(width=2, style=ep.Style(background="#33c481")),
            ep.Table(data=df),
        ],
        style=ep.Style(padding=1)
    ),
]

excel = ep.Excel(
    path=Path("filename.xlsx"),
    sheets=sheets,
)

ep.save(excel)

Result:

simple_example.png

Working with images

You can also add images to your Excel sheets. Auto-scale, based on PIL image size.

import excelipy as ep

sheets = [
    ep.Sheet(
        name="Hello!",
        components=[
            ep.Image(
                path=Path("resources/img.png"),
                width=2,
                height=5,
                style=ep.Style(border=2),
            ),
        ],
    ),
]

excel = ep.Excel(
    path=Path("filename.xlsx"),
    sheets=sheets,
)

ep.save(excel)

Result:

image_example.png

Advanced Example

import excelipy as ep

sheets = [
    ep.Sheet(
        name="Hello!",
        components=[
            ep.Text(
                text="This is my table",
                style=ep.Style(bold=True),
                width=4,
            ),
            ep.Fill(
                width=4,
                style=ep.Style(background="#D0D0D0"),
            ),
            ep.Table(
                data=df,
                header_style=ep.Style(
                    bold=True,
                    border=5,
                    border_color="#F02932",
                ),
                body_style=ep.Style(font_size=18),
                column_style={
                    "testing": ep.Style(
                        font_size=10,
                        align="center",
                    ),
                },
                column_width={
                    "tested": 20,
                },
                row_style={
                    1: ep.Style(
                        border=2,
                        border_color="#F02932",
                    )
                },
                style=ep.Style(padding=1),
            ).with_stripes(pattern="even"),
        ],
        style=ep.Style(
            font_size=14,
            font_family="Times New Roman",
            padding=1,
        ),
    ),
]

excel = ep.Excel(
    path=Path("filename.xlsx"),
    sheets=sheets,
)

ep.save(excel)

This is an exaggerated example, to show the capabilities of the package. You can see that for a table, you can define the header style, body style, column styles, row styles, and even the column widths. You can also add text and fill components to the sheet.

This is the result:

advanced_example.png

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

excelipy-0.1.5.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

excelipy-0.1.5-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file excelipy-0.1.5.tar.gz.

File metadata

  • Download URL: excelipy-0.1.5.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for excelipy-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ded2aa7b317fcf74c32ced9cd51ae928775d67eb41cf9a093d7af032fb874dd0
MD5 a34e839d531f2be33b147f73383f54e4
BLAKE2b-256 f853f091fc49f97b450c01ccd37f5817ab987849862e65c14027ce1a039490fc

See more details on using hashes here.

File details

Details for the file excelipy-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: excelipy-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.19

File hashes

Hashes for excelipy-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c6859e78b4528e8a08af8565d3722d30709685f03998ba439670dbd4d01b86eb
MD5 b7751c2eb38b6d1da5678358c193b555
BLAKE2b-256 c11503dc192a9b2b3b84ede16d4f6f2ae0e0c971066030868f171bad344d32b0

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