Repository navigation
Table Total Row turned on again: a custom total is its formula, and the first column keeps its own - #4386
Table Total Row turned on again: a custom total is its formula, and the first column keeps its own#4386Hamza0101 wants to merge 1 commit into
Conversation
table.totalRow wrote a custom column total (totalsRowFormula, kept in totals_label) as a text label, so SUM(B2:B3)+10 showed as that text. It is now written as the formula. Turning the row on also set the first column's label to Total whatever it held; now only a first column with no label or function of its own gets Total, so a label or function kept from when the row was turned off comes back, as in Excel.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…he first column keeps its own Upstream PR: storytold#4386 Head: 8ee422b
Merges the zcode-pr-transfer branch (61 commits transferring open, not-yet-merged upstream PRs into our fork) into main. Docs (docs/ui-parity.md, docs/file-format-parity.md) resolved in favor of main's current changelog state; code from all transferred PRs carried over cleanly. Commits carried over (21 from this session + 40 earlier transfers): storytold#4408, storytold#4405, storytold#4406, storytold#4386, storytold#4379, storytold#4378, storytold#4376, storytold#4375, storytold#4373, storytold#4370, storytold#4369, storytold#4348, storytold#4347, storytold#4345, storytold#4344, storytold#4343, storytold#4341, storytold#4340, storytold#4337, storytold#4336, storytold#4318, storytold#4316, storytold#4315, storytold#4312, storytold#4310, storytold#4307, storytold#4306, storytold#4305, storytold#4303, storytold#4298, storytold#4295, storytold#4287, storytold#4286, storytold#4257, storytold#4256, storytold#4254, storytold#4252, storytold#4251, storytold#4248, storytold#4244, storytold#4243, storytold#4229, storytold#4228, storytold#4227, storytold#4225, storytold#4221, storytold#4220, storytold#4219, storytold#4217, storytold#4424, storytold#4423, storytold#4420, storytold#4419, storytold#4418, storytold#4414, storytold#3617, storytold#2642, storytold#2556, storytold#2321
Refs #4296 (found while testing #4383)
What was wrong
A table whose Total Row is turned off keeps each column's calculation. Excel writes it to the file, and GridCraft reads it into
TableColumn::totals/totals_label. Turning the row back on withtable.totalRow(table_flagandwrite_totalsincrates/engine/src/cmd/insert/table.rs) didn't bring it back as Excel does:totalsRowFormulasuch asSUM(B2:B3)+10is kept intotals_label, andwrite_totalswrote it as a text label. B4 showedSUM(B2:B3)+10instead of 25.All groups), and wrote "Total" over a function it had (a Count).This happens on
mainwith any workbook read from such an Excel file. #4383 is separate: it keeps the calculation when GridCraft saves the file.What changed
write_totalswrites a custom column's total as its formula (=+totals_label). Built-in functions areSUBTOTAL(…)as before, and other labels stay text.QA report
Main vs branch, end to end (
gridcraft-cli run)source.xlsxhas a tableTable1(A1:C3; Group/Amount/Mean; Amount 7, 8 and Mean 1, 2). Its Total Row is off, and its hidden totals are in the issue's Excel form:totalsRowLabel="Total";customSUM(B2:B3)+10;average.The table was made by
gridcraft-cli, and its XML was patched by hand. Each build ranrun --in source.xlsx --cmd 'table.totalRow={"table":"Table1","on":true}' --out, and the saved file was evaluated.mainis agridcraft-clibuilt fromorigin/main(abcfc191); the branch is this PR (8ee422bc).SUM(B2:B3)+10, no formula=SUM(B2:B3)+10totalsRowLabel="All groups"in the fileItem/Qty, x 2, y 5; control)Test
tests::total_row_turned_on_again_restores_custom_totals_and_labelsputs the hidden-row table into the open workbook, turns the row on and covers:=SUM(B2:B3)+10and 25, C4 is the Average 1.5, and A4 is "Total";The existing Total Row tests (
tables_and_structured_refs,structured_refs_to_columns_with_edge_spaces, the last-row tests) still pass.Negative controls
Each was an edit on top of
8ee422bc, run, then restored withgit checkout:Null, right"=SUM(B2:B3)+10"Text("Total"), rightText("All groups")Gate (macOS arm64, at
8ee422bc)cargo fmt --all -- --checkcargo clippy -p gridcraft-engine --all-targets -- -D warningscargo test -p gridcraft-engine -p gridcraft-xlsxNot covered
main, so on its own a GridCraft save still drops it.cargo xtask ci: I didn't run the fullcargo xtask ci(wasm, layers, the other crates).Summary by CodeRabbit