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.1.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

poi-1.1.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poi-1.1.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.9.16 Darwin/22.6.0

File hashes

Hashes for poi-1.1.1.tar.gz
Algorithm Hash digest
SHA256 fcf1ca34025d81dc0582d17bcc99927bac6d09fecb18ec3daad0a9f22e5e8588
MD5 57fb2ca767bc4b4b1a8a4b594e26f065
BLAKE2b-256 f3a5801a860c2720a55d7c2c914b658058fd5ff2329a5482627cea28cccb29a1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: poi-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.9.16 Darwin/22.6.0

File hashes

Hashes for poi-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d90deb58a9f7a5d076c500704e2dd6c4d6221ed020cf312cb64dfb52b80a48a5
MD5 f5f46f683b727dc9a2b4a2c7d80a60dc
BLAKE2b-256 8a0fc4cd0b26df5fc9e03eb4e40e659ba2e70415b48f8a89e86f3bc66b86f28e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page