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

Uploaded Source

Built Distribution

poi-0.2.6-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poi-0.2.6.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.0 Darwin/20.5.0

File hashes

Hashes for poi-0.2.6.tar.gz
Algorithm Hash digest
SHA256 9d8d28eb9481f6c7813e4dad0f1a7dd83a9f4f58fd1486b0ac29434b3baecc9d
MD5 e25ead608c9135b4c56d32def8c9a400
BLAKE2b-256 a4a7345bb9e59aec29f56eec4b7a5bd02053eb9c474f9c26f69d9d923e88ad20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: poi-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.6 CPython/3.9.0 Darwin/20.5.0

File hashes

Hashes for poi-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 8d14f4455ca1f14a0bbdefb342b37e54f38546e778a305aac7668eadbe950767
MD5 369fdb1c73ca63147c3a37d33e10bddc
BLAKE2b-256 224cb7a3c522dd76a952e93bb72695068d90b545dc175c9560afeaf9de744780

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