poi


Namepoi JSON
Version 1.1.7 PyPI version JSON
download
home_pagehttps://github.com/baoshishu/poi
SummaryWrite Excel XLSX declaratively.
upload_time2023-10-10 02:49:58
maintainer
docs_urlNone
authorRyan Wang
requires_python>=3.8,<4.0
licenseMIT
keywords xlsx xlswriter excel declarative
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Poi: The Declarative Way to Excel at Excel in Python

![CI](https://github.com/ryanwang520/poi/actions/workflows/tests.yaml/badge.svg)

## 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

```bash
pip install poi
```

## Quick start

### Create a sheet object and write to a file.

```python
from poi import Sheet, Cell
sheet = Sheet(
    root=Cell("hello world")
)

sheet.write('hello.xlsx')
```

![hello](https://github.com/baoshishu/poi/raw/master/docs/assets/hello.png)

See, it's pretty simple and clear.


### Create a Dynamic Table with Conditional Formatting


```python
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")
```


![table](https://github.com/baoshishu/poi/raw/master/docs/assets/table.png)

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](https://ryanwang520.github.io/poi/)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/baoshishu/poi",
    "name": "poi",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "xlsx,xlswriter,excel,declarative",
    "author": "Ryan Wang",
    "author_email": "hwwangwang@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e2/e3/287a2264bc695ae625795e8143a8303e8cfc34901ed5dc9be1c7674cf6e1/poi-1.1.7.tar.gz",
    "platform": null,
    "description": "# Poi: The Declarative Way to Excel at Excel in Python\n\n![CI](https://github.com/ryanwang520/poi/actions/workflows/tests.yaml/badge.svg)\n\n## Why Poi?\n\nCreating 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.\n\n\n\n## Installation\n\n```bash\npip install poi\n```\n\n## Quick start\n\n### Create a sheet object and write to a file.\n\n```python\nfrom poi import Sheet, Cell\nsheet = Sheet(\n    root=Cell(\"hello world\")\n)\n\nsheet.write('hello.xlsx')\n```\n\n![hello](https://github.com/baoshishu/poi/raw/master/docs/assets/hello.png)\n\nSee, it's pretty simple and clear.\n\n\n### Create a Dynamic Table with Conditional Formatting\n\n\n```python\nfrom typing import NamedTuple\nfrom datetime import datetime\nimport random\n\nfrom poi import Sheet, Table\n\n\nclass Product(NamedTuple):\n    name: str\n    desc: str\n    price: int\n    created_at: datetime\n    img: str\n\n\ndata = [\n    Product(\n        name=f\"prod {i}\",\n        desc=f\"desc {i}\",\n        price=random.randint(1, 100),\n        created_at=datetime.now(),\n        img=\"./docs/assets/product.jpg\",\n    )\n    for i in range(5)\n]\ncolumns = [\n    {\n        \"type\": \"image\",\n        \"attr\": \"img\",\n        \"title\": \"Product Image\",\n        \"options\": {\"x_scale\": 0.27, \"y_scale\": 0.25},\n    },\n    (\"name\", \"Name\"),\n    (\"desc\", \"Description\"),\n    (\"price\", \"Price\"),\n    (\"created_at\", \"Create Time\"),\n]\nsheet = Sheet(\n    root=Table(\n        data=data,\n        columns=columns,\n        row_height=80,\n        cell_style={\n            \"color: red\": lambda record, col: col.attr == \"price\" and record.price > 50\n        },\n        date_format=\"yyyy-mm-dd\",\n        align=\"center\",\n        border=1,\n    )\n)\nsheet.write(\"table.xlsx\")\n```\n\n\n![table](https://github.com/baoshishu/poi/raw/master/docs/assets/table.png)\n\nSee how simple it is to create complex tables? You just wrote a dynamic Excel table with conditional formatting a few lines of code!\n\n\n### Features\n\n* \ud83c\udf89 Declarative: Create Excel files with a simple, intuitive DSL.\n* \ud83d\udd25 Fast: Export large Excel files in seconds.\n* \ud83d\ude80 Flexible Layouts: Create any layout you can imagine with our intuitive Row and Col primitives.\n\n\n### Documentation\n\nFor more details, check our comprehensive [Documentation](https://ryanwang520.github.io/poi/)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Write Excel XLSX declaratively.",
    "version": "1.1.7",
    "project_urls": {
        "Documentation": "https://baoshishu.github.io/poi/",
        "Homepage": "https://github.com/baoshishu/poi",
        "Repository": "https://github.com/baoshishu/poi"
    },
    "split_keywords": [
        "xlsx",
        "xlswriter",
        "excel",
        "declarative"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c25fe78a18bfce1fcc8b5157db035813ea94041dd2d8338f7730078f40aca8b4",
                "md5": "e7e3ed57be69ef62cf099be97d2b3e8f",
                "sha256": "cad5cb14a67b43714b17166084e4ff9cd1756ffe2a9534af6774ebbbeef3529f"
            },
            "downloads": -1,
            "filename": "poi-1.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e7e3ed57be69ef62cf099be97d2b3e8f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 11349,
            "upload_time": "2023-10-10T02:49:57",
            "upload_time_iso_8601": "2023-10-10T02:49:57.063157Z",
            "url": "https://files.pythonhosted.org/packages/c2/5f/e78a18bfce1fcc8b5157db035813ea94041dd2d8338f7730078f40aca8b4/poi-1.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2e3287a2264bc695ae625795e8143a8303e8cfc34901ed5dc9be1c7674cf6e1",
                "md5": "dd557055e7899b1784abe09aa280cace",
                "sha256": "954a9995c3a1f112efc620ffa0a6ab9485b0070fb9481c78ef155d7f1e53e466"
            },
            "downloads": -1,
            "filename": "poi-1.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "dd557055e7899b1784abe09aa280cace",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 10468,
            "upload_time": "2023-10-10T02:49:58",
            "upload_time_iso_8601": "2023-10-10T02:49:58.484041Z",
            "url": "https://files.pythonhosted.org/packages/e2/e3/287a2264bc695ae625795e8143a8303e8cfc34901ed5dc9be1c7674cf6e1/poi-1.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-10 02:49:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "baoshishu",
    "github_project": "poi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "poi"
}
        
Elapsed time: 0.16954s