Write Excel XLSX declaratively.
Project description
Poi: The Declarative Way to Excel at Excel in Python
Why Poi?
Creating Excel files programmatically has always been a chore. Current libraries offer limited flexibility, especially when you need more than a basic table. That's where Poi comes in, offering you a simple, intuitive, yet powerful DSL to make Excel files exactly the way you want them.
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.
Create a Dynamic Table with Conditional Formatting
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")
See how simple it is to create complex tables? You just wrote a dynamic Excel table with conditional formatting a few lines of code!
Features
- 🎉 Declarative: Create Excel files with a simple, intuitive DSL.
- 🔥 Fast: Export large Excel files in seconds.
- 🚀 Flexible Layouts: Create any layout you can imagine with our intuitive Row and Col primitives.
Documentation
For more details, check our comprehensive Documentation
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-1.1.6.tar.gz
(10.4 kB
view details)
Built Distribution
poi-1.1.6-py3-none-any.whl
(11.3 kB
view details)
File details
Details for the file poi-1.1.6.tar.gz
.
File metadata
- Download URL: poi-1.1.6.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 148f0483640e7fac1e96019cc1ca2a75e76f888764d8b54a489d1c5abfa0f8e0 |
|
MD5 | c033e014086f574143829224d408c44b |
|
BLAKE2b-256 | 598465fc4e3c7b0f364a3e692c543dafa08cf73fed8c44e99ab85ba3b11ab598 |
File details
Details for the file poi-1.1.6-py3-none-any.whl
.
File metadata
- Download URL: poi-1.1.6-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.12.0 Darwin/23.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec30a7bccb6e3fac8def8e1d2c2a36a21689bba7b00689ffe7bc40b07658253 |
|
MD5 | 26b5b513856e6a59aacb69b4c3a0842c |
|
BLAKE2b-256 | 09170cfb95a259a961ee21690e210f0f2515b353a20f6b92d7957bcecea5d2c6 |