WolfPPT - Documentation

# How do I edit PPTX text, table cells, and chart data with WolfPPT?

Use run.text for a replacement within an existing run, table.cell(row, column).text for a table value, and chart.replace_data(data) for category chart data. The runnable example uses WolfPPT 0.1.6 plus python-pptx 1.0.2 helper types, not helper namespaces missing from that WolfPPT wheel.

Last updated: November 9, 2026.

[WolfPPT documentation](https://wolfppt.com/docs)

## Install the dependencies this example actually uses

Run python -m pip install wolfppt==0.1.6 python-pptx==1.0.2. The Presentation facade comes from WolfPPT; CategoryChartData, XL_CHART_TYPE, and Inches come from python-pptx. The published WolfPPT 0.1.6 wheel checked here does not contain wolfppt.chart, wolfppt.enum, or wolfppt.util. Keeping these imports explicit avoids presenting current-source convenience modules as available in an older wheel.

The first half builds a synthetic report with a text box, a table, and a clustered column chart, then saves it as the input. This setup makes every selected position and chart series known. In an existing company deck, inspect slide and shape identities before choosing targets. Do not assume that the first table or chart in iteration order is the approved reporting object.

## Change text at the intended level

The replacement traverses text frames, paragraphs, and runs, changing the month token only where the complete token occurs inside one run. Editing that run avoids replacing the complete text frame. This is useful when the run already carries the formatting that should remain attached to the new value. The example does not apply an independent formatting override.

A visible word or placeholder may be split across multiple runs. This simple loop will not find such a token, and it is not a regex or cross-paragraph replacement engine. Do not broaden its claim to arbitrary templating. If your input has split tokens, inspect the paragraph structure and qualify the chosen replacement operation against the installed release rather than concatenating text and discarding its formatting.

## Complete example

```
from wolfppt import Presentation
from pptx.chart.data import CategoryChartData
from pptx.enum.chart import XL_CHART_TYPE
from pptx.util import Inches

seed = Presentation()
slide = seed.slides.add_slide(seed.slide_layouts[6])
slide.shapes.add_textbox(0, 0, Inches(5), Inches(1)).text = "Revenue: {{month}}"
table = slide.shapes.add_table(2, 2, 0, Inches(1), Inches(4), Inches(1)).table
table.cell(0, 0).text = "Revenue"
table.cell(1, 1).text = "$4.0M"
data = CategoryChartData()
data.categories = ["Q1", "Q2"]
data.add_series("Revenue", [4.0, 4.1])
slide.shapes.add_chart(XL_CHART_TYPE.COLUMN_CLUSTERED, 0, Inches(3), Inches(5), Inches(3), data)
seed.save("report.pptx")

prs = Presentation("report.pptx")
for shape in prs.slides[0].shapes:
    if shape.has_text_frame:
        for paragraph in shape.text_frame.paragraphs:
            for run in paragraph.runs:
                run.text = run.text.replace("{{month}}", "November")
    if shape.has_table:
        shape.table.cell(1, 1).text = "$4.2M"
    if shape.has_chart:
        replacement = CategoryChartData()
        replacement.categories = ["Q1", "Q2"]
        replacement.add_series("Revenue", [4.0, 4.2])
        shape.chart.replace_data(replacement)
prs.save("report-updated.pptx")
reopened = Presentation("report-updated.pptx")
assert reopened.slides[0].shapes[0].text == "Revenue: November"
assert reopened.slides[0].shapes[1].table.cell(1, 1).text == "$4.2M"
assert list(reopened.slides[0].shapes[2].chart.series[0].values) == [4.0, 4.2]
```

## Select table coordinates and replace chart data

The cell assignment uses row one and column one, which are the second row and second column because the indices start at zero. It changes that cell text, not the entire table. It does not infer currency, calculate totals, insert a new reporting row, or decide which cell is the business metric. Formatting the replacement dollar value is the caller responsibility.

The chart replacement creates a fresh CategoryChartData object with the two known categories and one Revenue series. Its values are complete series data, not a request to calculate a workbook. This example retains the same categories and series order. It does not claim that arbitrary chart families, changed cardinalities, or business-key reordering have the same style and preservation behavior.

## Verify the saved result, not just the assignment

After saving report-updated.pptx, the script reopens it and asserts the text, cell value, and numeric chart-series values. These checks prove the selected synthetic edits. They are not a visual comparison with Microsoft PowerPoint, a full-package schema result, or evidence that every chart type has been covered. Use representative source decks before replacing an existing reporting path.

For a recurring report where source drift must refuse the update, look at Commercial reporting. That interface binds targets to a source digest, shape identity, and expected old values, then reports its own verification result. Ordinary facade editing and guarded report publication solve different problems. Keep their error handling, publication policy, and evidence separate instead of interpreting save() as a source-bound receipt.

## Evaluation boundary

Use the three reopened assertions as a starting point for business-level acceptance. In a larger report, assert every intended cell and series rather than merely checking that the presentation opens. Conversely, do not infer that every unchanged shape was verified from an assertion on one edited value. Choose preservation checks separately for the package content that must remain untouched.

## What it does not do

- The run loop does not match tokens split across runs.
- This sample covers one category chart type with fixed categories and series order.
- Chart-data replacement is not spreadsheet formula recalculation.
- Text replacement does not establish that a longer value fits the slide.

## Related documentation and tasks

- [How do I open, inspect, edit, and save a PPTX with WolfPPT?](https://wolfppt.com/docs/quickstart)
- [Which WolfPPT Python APIs work in the published 0.1.6 package?](https://wolfppt.com/docs/api-reference)
- [How do I refresh a PPTX report and handle WolfPPT refusals?](https://wolfppt.com/docs/reports-refusals)
- [Update PPTX table cells](https://wolfppt.com/update-pptx-table-python)
- [Update PPTX chart data](https://wolfppt.com/update-pptx-chart-python)
