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+.

Quick start

Create a sheet object and write to a file.

from poi import Sheet
sheet = Sheet(
    root=Col(
        colspan=8,
        children=[
            Row(
                children=[
                    Cell(
                        "hello",
                        offset=2,
                        grow=True,
                        bg_color="yellow",
                        align="center",
                        border=1,
                    )
                ]
            ),
        ],
    )
)
sheet.write('hello.xlsx')

See, it's pretty simple and clear.

Sample for rendering a simple table.

class Record(NamedTuple):
    name: str
    desc: str
    remark: str

data = [
    Record(name=f"name {i}", desc=f"desc {i}", remark=f"remark {i}")
    for i in range(3)
]
columns = [("name", "名称"), ("desc", "描述"), ("remark", "备注")]
sheet = Sheet(
    root=Table(
        data=data,
        columns=columns,
        cell_width=20,
        cell_style={
            "bg_color: yellow": lambda record, col: col.attr == "name"
            and record.name == "name 1"
        },
        date_format="yyyy-mm-dd",
        align="center",
        border=1,
    )
)
sheet.write('table.xlsx')

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.3.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

poi-0.2.3-py3-none-any.whl (9.1 kB view hashes)

Uploaded Python 3

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