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 Python 3.7+.
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')
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")
Project details
Release history Release notifications | RSS feed
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.4.tar.gz
(9.0 kB
view details)
Built Distribution
poi-0.2.4-py3-none-any.whl
(9.3 kB
view details)
File details
Details for the file poi-0.2.4.tar.gz
.
File metadata
- Download URL: poi-0.2.4.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.0 Darwin/19.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 320c5e451a23c443bbb8a2f5a00266115c41fbb29d94c636ff65bf87ff57235d |
|
MD5 | b2598cdc3755b5c7113575053443b018 |
|
BLAKE2b-256 | 85cbd539ed8fa56a7eaeefbf44dd5a816de0dce4b95f5dc26f1f462da0e75f74 |
File details
Details for the file poi-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: poi-0.2.4-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.8.0 Darwin/19.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67e5099125fd4cbec63a1575b559f2f36bea1016876a6ba3e1ffa1a3c0273e91 |
|
MD5 | dda29a3731245e7d8266d5f4f1bd436c |
|
BLAKE2b-256 | f1f5bacb14d66b3807d55b53bcdd55a37fc2b303990a21348c695dc4a8dcb027 |