Skip to main content

Write Excel XLSX declaratively.

Project description

Poi: Make creating Excel XLSX files fun again.

travis

Poi helps you write Excel sheet in a declarative way, ensuring you have a better Excel writing experience.

It only supports Python 3.7+.

Documentation

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.

Sample for rendering a simple table.

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

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

Uploaded Source

Built Distribution

poi-1.0.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for poi-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d69ed5d6adb7025b902667db96f54d44134990b134e1292fcc236bab1e00721d
MD5 c0de3670d803ed7256372094799822e8
BLAKE2b-256 fe058f95963e7ec6290cea116df1602112ffe944b6624e644e3f3326553540e3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for poi-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d5e50d480a35eac8a5aaf6ab9a1d6eabb030b0ef7a527a0d9eabd8523ff8bf1
MD5 47dbb9ec614b7c0ffa91cec265950731
BLAKE2b-256 07d25cb1da8f13c14b662dafc2077992124c7d721d59215f01d5b4ddcb8f5c0f

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