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+.
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')
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.8.tar.gz
(9.4 kB
view details)
Built Distribution
poi-0.2.8-py3-none-any.whl
(10.0 kB
view details)
File details
Details for the file poi-0.2.8.tar.gz
.
File metadata
- Download URL: poi-0.2.8.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.0 Darwin/21.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbb903cf0d1563aa6c35fc1695d1c46d1d7573888fe13d98eda459c06b7b5c54 |
|
MD5 | 74d4c5723b9b16ab250b6c6bec783478 |
|
BLAKE2b-256 | 2456a97f27cf504e482948252be0042a557eda3df1c55542b7450535db6a7cc4 |
File details
Details for the file poi-0.2.8-py3-none-any.whl
.
File metadata
- Download URL: poi-0.2.8-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.0 Darwin/21.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5fe300c7d5bdf9eb945065b75b9265c1a5c13e0bcccf67f5ed5c08dddc572d48 |
|
MD5 | 0d10b8ff06cdf7fa880957134cf70903 |
|
BLAKE2b-256 | b0f251c3d97b189278c4c9a3003dcf50a16978ea727559541cd748587b0f2067 |