Table

Tables have a simple wrapper that makes table creation easier.

Let's look at the simplest table.

import tppt

(
    tppt.Presentation.builder()
    .slide(
        lambda slide: slide.BlankLayout()
        .builder()
        .table(
            [
                ["Price", "Name", "Quantity"],
                ["100", "Apple", "10"],
                ["200", "Banana", "20"],
            ],
            left=(1, "in"),
            top=(1, "in"),
            width=(5, "in"),
            height=(2, "in"),
        )
    )
    .build()
    .save("simple.pptx")
)

It's easy to understand.

In addition to this, tppt supports polars, pandas, pydantic, and dataclass to handle data analysis results.

import tppt
from tppt._features import USE_POLARS, PandasDataFrame

if USE_POLARS:
    df = PandasDataFrame(
        [
            {"Price": 100, "Name": "Apple", "Quantity": 10},
            {"Price": 200, "Name": "Banana", "Quantity": 20},
        ]
    )

    (
        tppt.Presentation.builder()
        .slide(
            lambda slide: slide.BlankLayout()
            .builder()
            .table(
                df,
                left=(1, "in"),
                top=(1, "in"),
                width=(5, "in"),
                height=(2, "in"),
            )
        )
        .build()
        .save("simple.pptx")
    )