Skip to main content

Write Excel XLSX declaratively.

Project description

Poi: The Declarative Way to Excel at Excel in Python

CI

Why Poi?

Creating Excel files programmatically has always been a chore. Current libraries offer limited flexibility, especially when you need more than a basic table. That's where Poi comes in, offering you a simple, intuitive, yet powerful DSL to make Excel files exactly the way you want them.

Installation

pip install poi

Quick start

Create a sheet object and write to a file.

from poi import Sheet, Cell
sheet = Sheet(
    root=Cell("hello world")
)

sheet.write('hello.xlsx')

hello

See, it's pretty simple and clear.

Create a Dynamic Table with Conditional Formatting

from typing import NamedTuple
from datetime import datetime
import random

from poi import Sheet, Table


class Product(NamedTuple):
    name: str
    desc: str
    price: int
    created_at: datetime
    img: str


data = [
    Product(
        name=f"prod {i}",
        desc=f"desc {i}",
        price=random.randint(1, 100),
        created_at=datetime.now(),
        img="./docs/assets/product.jpg",
    )
    for i in range(5)
]
columns = [
    {
        "type": "image",
        "attr": "img",
        "title": "Product Image",
        "options": {"x_scale": 0.27, "y_scale": 0.25},
    },
    ("name", "Name"),
    ("desc", "Description"),
    ("price", "Price"),
    ("created_at", "Create Time"),
]
sheet = Sheet(
    root=Table(
        data=data,
        columns=columns,
        row_height=80,
        cell_style={
            "color: red": lambda record, col: col.attr == "price" and record.price > 50
        },
        date_format="yyyy-mm-dd",
        align="center",
        border=1,
    )
)
sheet.write("table.xlsx")

table

See how simple it is to create complex tables? You just wrote a dynamic Excel table with conditional formatting a few lines of code!

Features

  • 🎉 Declarative: Create Excel files with a simple, intuitive DSL.
  • 🔥 Fast: Export large Excel files in seconds.
  • 🚀 Flexible Layouts: Create any layout you can imagine with our intuitive Row and Col primitives.

Documentation

For more details, check our comprehensive Documentation

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

poi-1.2.6.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

poi-1.2.6-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file poi-1.2.6.tar.gz.

File metadata

  • Download URL: poi-1.2.6.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for poi-1.2.6.tar.gz
Algorithm Hash digest
SHA256 ea92565ced5de2056b4bac745a8d4bcd54abee392710869b9d2c84f53001fe19
MD5 8af09ca5c8ad581e2c967241aca00bd4
BLAKE2b-256 75f42febf15e9e971b8583f910e5686fe590bdae2cb74dd609b29235579c11cf

See more details on using hashes here.

File details

Details for the file poi-1.2.6-py3-none-any.whl.

File metadata

  • Download URL: poi-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.11

File hashes

Hashes for poi-1.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 511d6823227969cfcc7747cc0beff87f7b2390f97a2e411491d9e8fc0a030d69
MD5 deacf88500d26a31ecbf0673509c8855
BLAKE2b-256 b28cd218a34a26a9ddedf3c533877eb53d23676387c0e6338c000545f480e60c

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