docxchart
Edit the data behind Word charts without disturbing the formatting.
Extract every chart's values from a .docx to JSON, edit the JSON, apply it
back. Fills, label positions, axis settings and theme bindings are never
touched.
Status: early. Handles same-length value edits on standard category charts. Anything it can't handle raises rather than guessing — see Limitations.
Install
pip install docxchart
Requires Python 3.11+.
CLI
docxchart list report.docx
docxchart extract report.docx -o data.json
docxchart apply report.docx --data data.json -o report-updated.docx
| Command | |
|---|---|
list FILE |
chart keys, titles, and shape |
extract FILE [-o OUT] |
write chart data to JSON (default data.json) |
apply FILE --data JSON [-o OUT] |
write edited data back to a new docx |
--sidecar |
on extract, also emit the internal manifest |
apply never writes in place. Omit -o and it errors.
Data format
{
"_docxchart": {
"source": "report.docx",
"basedOn": "sha256:1f3a…",
"extractedAt": "2026-07-29T09:14:22Z",
"formatVersion": "1.0"
},
"charts": [
{
"key": "revenue_by_quarter",
"_meta": {
"title": "Revenue by Quarter",
"type": "barChart",
"keyStable": true,
"readOnly": true
},
"series": [
{ "name": "2024", "formatCode": "#,##0" },
{ "name": "2025", "formatCode": "#,##0" }
],
"rows": [
{ "category": "Q1", "2024": 120, "2025": 130 },
{ "category": "Q2", "2024": null, "2025": 110 },
{ "category": "Q3", "2024": 95, "2025": 99 }
]
}
]
}
| Field | |
|---|---|
key |
chart identifier (see Naming) |
_meta |
read-only. apply errors if changed. |
series |
display order of the series. Order matters for legend and stacking. |
rows |
one row per category. Series values keyed by series name. |
basedOn |
hash of the source docx. apply refuses if the file has changed since extract. |
null is a genuine blank in the chart, rendered as a gap. It is not zero.
Omitting a key means the same thing.
Dates are stored as Excel serial numbers with a formatCode, and are passed
through unconverted.
Python API
from docxchart import ChartDoc
doc = ChartDoc.open("report.docx")
list(doc.charts)
# ['revenue_by_quarter', 'headcount']
chart = doc.charts["revenue_by_quarter"]
chart.table
# ChartTable(
# categories=['Q1', 'Q2', 'Q3'],
# series=[Series(name='2024', values=[120, None, 95])],
# )
chart.table.series[0].values = [130, 110, 99]
doc.validate() # -> list[Finding]
doc.save("report-updated.docx")
ChartTable and Series are plain dataclasses. No XML is exposed.
Naming
Charts are identified by their Alt Text, which survives Word re-saves, insertions and deletions — unlike file paths and relationship IDs.
- Right-click the chart → Edit Alt Text
- Enter a key, e.g.
revenue_by_quarter
Without Alt Text, the key falls back to the chart's title, slugified. This
works, but the key changes if anyone edits the title. list marks these as
unstable. Duplicate titles are suffixed by document order: revenue,
revenue-2.
Limitations
Unsupported cases raise UnsupportedChart or UnsupportedEdit with a reason.
Nothing is written on a partial or best-guess basis.
Not supported:
- Adding or removing categories — values can be changed, not the number of them
- Adding or removing series
- Scatter and bubble charts
chartExtypes: waterfall, treemap, sunburst, funnel, histogram, box & whisker, map- Multi-level category axes
- Charts in headers, footers or footnotes
- Charts bound to an external data source
- Any change to appearance — colours, fonts, chart type, axis config and layout are read-only
Charts must be created in Word. docxchart only rebinds data on charts that
already exist.
Notes
Word renders from the chart's cached values, not from the embedded workbook, but
the workbook is what you see when you click Edit Data. docxchart always
writes both, so the two never disagree.
Parts of the package that weren't changed come out byte-identical.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docxchart-0.1.1.tar.gz.
File metadata
- Download URL: docxchart-0.1.1.tar.gz
- Upload date:
- Size: 35.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072a75c7d1bc46327193713f948c95bacb60045ba5abcaeaad7ff127ea9abd2f
|
|
| MD5 |
d01eca292857b090447b4f703ce93cbe
|
|
| BLAKE2b-256 |
59bb7c8c50df297d8369c8ebe03fbbbe9a4d1c8c9508e36de3ca55b448e65c0d
|
File details
Details for the file docxchart-0.1.1-py3-none-any.whl.
File metadata
- Download URL: docxchart-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6554473f9c07ee8d7d33ef0aa8f30b57895d4496e063a03a60ff1daa3801ab6c
|
|
| MD5 |
ca36b098fe62c436dabf7988205d463a
|
|
| BLAKE2b-256 |
cdc45d19cf7f7e75923b7fd12b2846e1c4c2b8c6a0510d3d2400d6a1b1952a83
|