Repository navigation
Conversation
pierrevbc
force-pushed
the
chart-workbook
branch
2 times, most recently
from
October 13, 2026 11:52
093cf08 to
77dc432
Compare
Main keeps an unchanged chart's embedded workbook (storytold#355), but a chart made in DeckCraft, or one whose data or options changed, was written with no workbook: no part under ppt/embeddings/, no package relationship, no c:externalData. PowerPoint's Edit Data had nothing to open. - Export: an unchanged chart still goes back with its kept parts; an edited or new chart gets a workbook generated from its data, laid out where the chart part's formulas point (Sheet1, categories in A, one column per series), with its c:externalData. - Scatter series with different X values and multi-series bubble charts get their own columns instead of overlapping ranges. - ChartKept::workbook finds the kept workbook part. - The plain-chart fallback of an Office 2016 chart gets none: the workbook belongs to the chartEx part.
Every chart command clears the original chart part, so any edit (a new title, another chart type, a legend) made the export drop the chart's workbook for a generated one: extra sheets, formulas and formatting were lost even when the data had not changed. - Model: Chart.source, the series formulas of the imported chart part (name, categories or X values, values, bubble sizes) with the data as read. Commands keep it. - Export: when the data still fits the original ranges, the chart part is written with its original formulas. Unchanged data keeps the kept workbook byte for byte; changed data rewrites only the changed cells in it. Every other zip entry is copied as is. - Cells keep their style; a new name in a table header renames the table column; a value typed over a formula replaces it and drops the calculation chain; fullCalcOnLoad is set when the workbook holds formulas. - Series or points added or removed, a category chart turned into a scatter chart (or back), literal data, shared or array formulas, a table column name that would clash or is used by a structured reference: the workbook is generated from the chart data, as before.
pierrevbc
force-pushed
the
chart-workbook
branch
from
October 15, 2026 12:34
77dc432 to
a01e062
Compare
anishguduru
pushed a commit
to anishguduru/deckcraft
that referenced
this pull request
Oct 16, 2026
…om (storytold#241) - The wheel turns pages in single-page view: one per notch, one per swipe. - The rail's Page display menu offers Acrobat's view choices. - Preferences: default page display and default zoom. - Fit page and Fit height no longer jump across mixed page sizes.
Contributor
|
An embedded workbook would let users edit chart data in PowerPoint, closing the high-priority chart interoperability gap. If you would rather not, I can open a PR that credits you, keeps your commits and shows a git range-diff against this one, so you'll still get credit and have visible work. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since #355, an unchanged chart keeps the embedded workbook it was read with (and the other parts
its relationships reach, in
Chart.kept) when the presentation is saved as PPTX. What is stilllost:
chart.type,chart.data,chart.options) clearsChart.raw, so after a title change, a new legend or one changed valuethe chart is no longer "unchanged" and is saved without
c:externalDataor a workbook. Edit Datain other presentation apps has nothing to open, and the workbook's other sheets, formulas and
formatting are gone.
Reproduce on
mainwith a public file, not for committing:features/steps/test_files/cht-charts.pptxfrom scanny/python-pptx (commit278b47b), ortest-data/slideshow/aascu.org_hbcu_leadershipsummit_cooper_.pptxfrom apache/poi (slides 6and 7, one chart each).
deckcraft-cli run --in cht-charts.pptx --cmd 'chart.options={"title":"New"}' --export out.pptx(any chart command), or insert a chart and export.
unzip -l out.pptx | grep embeddingsprints nothing for that chart; itschartN.xmlhas noc:externalData.Design
The workbook stays where #355 put it: in
Chart.kept, the package parts an imported chart pointsat. No new media item, no new field for it in the model.
ChartKept::workbook()finds the keptworkbook part (the internal
packageoroleObjecttarget of the chart's relationships).On export,
Exp::chart_rel:original part goes back with every kept part under fresh
keptNnames.Chart.source, commit 2): thechart part is written from the model with its original formulas, and the kept workbook is
written next to it: byte for byte when only the presentation changed (title, type, legend…),
with only the changed cells rewritten when the data changed.
generated from the chart data, laid out where the generated chart part's formulas point, with
its
c:externalData.An Office 2016 chart's plain-chart fallback gets no workbook, as with #355: it belongs to the
chartExpart.What changes
Two commits, then a separate one adding my entry to
contributors/people.toml(
[people.pierrevbc], display name only).1. pptx: write a workbook for edited and new charts
ChartKept::workbook().sheet,
Sheet1, inline strings; categories in column A, one column per series, series names onrow 1) under
ppt/embeddings/workbook{n}.xlsx, apackagerelationship andc:externalData.get columns of their own. Before, every scatter series pointed at column A for its X values and
bubble sizes used
col(i + 2), which overlapped the next series' values.chart_embed.rs: the fixtures strip the workbook the writer now generatesfor a new chart (to stand for a file from an app that writes none);
an_edited_chart_does_not_write_a_stale_workbooknow checks that the stale bytes are notwritten and that the chart gets one workbook of its own data.
2. pptx: update chart workbooks in place instead of rebuilding them
Chart.source: Option<ChartSource>: for each series of an imported chart, theformulas of its name, categories (or X values), values and bubble sizes (
c:f), and the data thechart part cached for them. Commands leave it alone, unlike
raw. Skipped when absent, soexisting
.deckcraftfiles serialize as before.counts, same category or XY family, formulas present), the chart part is written with its
original formulas and the kept workbook is written back byte for byte.
the kept workbook (
crates/pptx/src/write/xlsx.rs, quick-xml and zip, no new dependency, nofile or network I/O). Every other zip entry is copied with its compressed bytes. In the
workbook:
calcChain.xml(with its relationship andcontent type) is dropped so Excel does not repair the file; Excel rebuilds it;
fullCalcOnLoad="1"is set oncalcPrwhen the workbook holds formulas, so formulaselsewhere follow the new values.
were added or removed; a category chart became a scatter or bubble chart (or back); the chart
part held literal data; a formula is not one row or column of one sheet (unions, names, other
workbooks); a target cell holds a shared or array formula; a new table column name is empty,
clashes with another column, or appears in a structured reference; a linked workbook's data
changed; the workbook is an older OLE embedding.
How it was tested
cargo xtask cipasses on this branch, onmainat 9859da3 (all 7 steps: fmt, pdf-deps, clippy-D warnings, 1,687 tests passed and 6 ignored, assets, layers, wasm32 check). On Windows thedeckcraft-ui-eguilib tests sometimes crash with an access violation when run in parallel, onmainas well; the run above usedRUST_TEST_THREADS=1.New and changed tests, all on decks and workbooks built in code:
write::chartunit tests: for 11 chart variants (column, stacked bar, line, pie, radar, combo,scatter with shared and with separate X values, single-series bubble, multi-series bubble with
shared and with separate X values), every cached value in the chart part equals the workbook
cell its formula points to; an unchanged chart keeps its part; edited data leaves that path.
write::xlsxunit tests: formula parsing (quoted sheet names, one row or one column only),cells replaced and inserted in order (including new rows and an empty
sheetData), sharedformulas and implicit positions refused,
calcPrset or inserted at its schema position, tablecolumns renamed.
tests/chart_workbook.rs, on a workbook built by the test (aChart datasheet with a table, atotal in F2, a formula in D5, a
Notessheet with a formula into the first one, shared strings,a calculation chain): title, legend and type changed keep the workbook byte for byte; one value
changed rewrites only that cell and sets
fullCalcOnLoad; a renamed series renames the tablecolumn; a value over a formula drops the formula and the calculation chain; added series or
points and a clashing series name rebuild the workbook; a scatter chart updates in place; a chart
made in DeckCraft gets a generated workbook, updated in place after a re-import.
tests/roundtrip.rsandtests/chart_embed.rs(Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355): workbook bytes across round trips,unchanged charts still keep their parts under
keptNnames, thechartExfallback has none.Checked by hand earlier on the same logic (0.5.0, public decks above, not committed): changing the
title and legend keeps every workbook byte for byte; changing one value changes one cell of one
sheet, every other workbook entry (thumbnail included) staying identical; openpyxl and LibreOffice
read the updated workbooks.
Not verified: PowerPoint's Edit Data and Excel's recalculation on the updated workbooks. That needs
a black-box check on a machine with PowerPoint (AGENTS.md §2).
Known limits
Chart.kept, which a.deckcraftsave doesn't store (Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355): a deck savedas
.deckcraftand reopened has no kept workbook, so an export writes a generated one.formatting, and an edited chart drops the other kept parts (styles, drawings), as with Charts: keep the embedded workbook when a chart is saved unchanged (#335) #355.
before. Only the workbook is kept.
[Name],[@Name]); escaped names in formulasmay be missed.
dimensionand rowspanshints are not updated.Related PRs
ChartKeptand leaves its unchanged-chart path as it is.git merge-treeagainstmainat 9859da3 is clean.