Skip to main content

Write Excel XLSX declaratively.

Project description

Poi: Make creating Excel XLSX files fun again.

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

It only supports 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.1.8.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

poi-0.1.8-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: poi-0.1.8.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/19.0.0

File hashes

Hashes for poi-0.1.8.tar.gz
Algorithm Hash digest
SHA256 2ad6f5a7ec9618ad24bb515d4d88bf27c9c8532c6b2980b692fc10d9a08f4dec
MD5 1e50b1ac74715696e5223992820bb6b3
BLAKE2b-256 d5bcf7badaa1f34356942e5c349c618d2141c82e731bf55fba11772a3b1bafe5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: poi-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.17 CPython/3.7.4 Darwin/19.0.0

File hashes

Hashes for poi-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5f56152fc0c3541c494cb349e2d09df89fb84e1ff8b95b5a08a29e1fcf75c1ac
MD5 7b3bd772d3b29fdc67e798688f6e4cee
BLAKE2b-256 0fe174a8f75d4ad8edd028b94fd93ac352be290eff75137ae739ac8df31f83aa

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