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.5.tar.gz
(9.0 kB
view details)
Built Distribution
poi-0.2.5-py3-none-any.whl
(9.3 kB
view details)
File details
Details for the file poi-0.2.5.tar.gz
.
File metadata
- Download URL: poi-0.2.5.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 | fd67186d27d8f9336a1fff63da2d6556abc6ea1de0b954486c74c433d214afcc |
|
MD5 | 11f483c6771b848349b9f1fabb6c300c |
|
BLAKE2b-256 | 0b22ab1e1f1b0c62c80987222b5b236c3b2bea10997fd04da8be3d6e447c45d0 |
File details
Details for the file poi-0.2.5-py3-none-any.whl
.
File metadata
- Download URL: poi-0.2.5-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 | 9e4f7ff6ac5dc7d909fc4fbad7a9125de367ef2451b279a97196d5b6daf64f3f |
|
MD5 | 848ce2b7da9695ec9c6346f8ce87b1f9 |
|
BLAKE2b-256 | b8e2597d19e186b7b198260a00f6a8e7ece12314239dcfc02d97183791685b4e |