Skip to main content

Simple unofficial Python library for generating PowerPoint presentations using Think-cell

Project description

ThinkcellBuilder 📊

CI codecov PyPI version shields.io Supported Python versions Code style: black Downloads GitHub license

ThinkcellBuilder is a simple unofficial Python library used to build powerpoint presentations with Think-cell charts, textboxes, and tables.

This project builds on Duerto's think-cell package.

ThinkcellBuilder allows the user to automate data entry for all named Think-cell objects (e.g., charts, textfields, tables), except Gantt charts, on a powerpoint template. It also provides a presentation abstraction so that one can create a whole presentation using combinations of slide templates and charts.

This package outputs .ppttc files that, when opened with Think-cell, build powerpoint presentations. A think-cell license and installation license is not required to use this package, but one is needed to build the presentation. Pptc files are just

Installation

ThinkcellBuilder is available on PyPi.

 $ pip install thinkcellbuilder

Tutorial and usage

Let us say you have generated a template according to think-cell's automation guidelines called simple-template.pptx with the following chart called Chart1:

The thinkcell library helps you generate a .ppttc file so that you can generate presentations based on that template using python:

from thinkcellbuilder import Presentation, Template

# create a presentation object
presentation = Presentation()

# create template object, this usually represents one or a small number of slides
slide1 = Template("Company Performance Template.pptx")
# add your text field
slide1.add_textfield(
    name="Slide Title",
    text="Company Performance",
)
# add data for a chart named Chart1
slide1.add_chart(
    name="Chart1",
    categories=["Ads", "Revenue", "Losses"],
    data=[["Amazon", 1, 11, 14], ["Slack", 8, 2, 15], ["Uber", 1, 2, 12]],
)

# add slide1 to the presentation
presentation.add_template(slide1)

# create another slide from a different template
slide2 = Template("Company Forecast Template.pptx")
# add a text field
slide2.add_textfield(
    name="Slide Title",
    text="Tech Forecasts",
)
# add data for a chart named Chart1
slide2.add_chart(
    name="Chart1",
    categories=["3yr", "5yr", "10yr"],
    data=[["Amazon", 3, 10, 17], ["Slack", 8, 12, 15], ["Uber", 1, 2, 3]],
)

# add slide2 to the presentation
presentation.add_template(slide2)

# save the ppttc file 
presentation.save_ppttc(path="simple-example.ppttc")

Once done, go ahead and double click the generated simple-example.ppttc file. Think-cell will populate your charts/text fields based on the code above and open a powerpoint presentation. Save it and you are done!

You can also derive your chart from a Pandas dataframe.

Make sure you have pandas installed (e.g., pip install pandas)

from thinkcellbuilder import Presentation, Template
import pandas as pd

df = pd.DataFrame(
    columns=["Company", "Ads", "Revenue", "Losses"],
    data=[["Amazon", 1, 11, 14], ["Slack", 8, 2, 15], ["Ford", 1, 2, 12]],
)

slide = Template("simple-template.pptx") # create template object
slide.add_chart_from_dataframe(
    name="Chart1",
    dataframe=df,
) # add your dataframe

presentation = Presentation()
presentation.add_template(slide)
tc.save_ppttc(path="simple-example.ppttc")

Visit the examples folder for more examples and source files.

If you wish to learn more about this process, visit the think-cell automation documentation.

Dependencies

ThinkcellBuilder has no dependencies outside the Python standard library. If you want to create charts from pandas dataframes, pandas is obviously needed.

Limitations

It is currently impossible to derive the types or names of Think-cell objects (e.g., charts, named textfields, etc.) in a template programatically, so all automation methods rely on typo-free expression of object names. Mis-typed chart names are silently ignored by Think-cell when it is building the presentation, so please double check your object names and types.

Contributing

Start by forking this repo.

Install the development dependencies (you probably want to do this in a virtual environment):

 $ pip install -r requirements-dev.txt

Make sure the tests run:

 $ pytest

Create a branch and submit a pull request.

Note: This project is in no way affiliated with think-cell Sales GmbH & Co. KG. I just wanted to make my (and hopefully your) life easier.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ThinkcellBuilder-0.1.1.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ThinkcellBuilder-0.1.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file ThinkcellBuilder-0.1.1.tar.gz.

File metadata

  • Download URL: ThinkcellBuilder-0.1.1.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for ThinkcellBuilder-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1e03d20f24758cb0539d46df4e399ff648b91e06751e5a1134810c7a82eed00
MD5 f746f7de95b2ae345c4e8db8216703bf
BLAKE2b-256 7c2ddf2aa6b310964351a6d80a196d6b6c6a3926a337eaecc848d18189018b5b

See more details on using hashes here.

File details

Details for the file ThinkcellBuilder-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ThinkcellBuilder-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12040ff5948489e705e4b65bef617fa74c315ce0f90f8d369fd2904f719d6c1f
MD5 db2e4fc75b5acd089506ef3539af9566
BLAKE2b-256 8b5da31aa51d382fc9f863e81ac43b5974adca169964cf2bffef8dce8c372d51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page