Files
gridcraft/crates/engine/tests/it/sheet_copy_spill.rs
T
nihilist-narwhal f32fefddcf Tables never hold merged cells, which Excel removes the table for on open
A table with a merged cell in it opened in Excel with the repair prompt, and Excel removed the
table and its AutoFilter ("Removed Feature: Table from /xl/tables/table1.xml"). GridCraft let
merged cells into a table four ways; each now does what Excel does:

- Merge Cells, Merge & Center and Merge Across refuse a range that touches a table ("You can't
  merge cells in a table."). Unmerging is still allowed, so a file that has one can be fixed.
- Insert Table / Format as Table and Resize Table unmerge the merged cells the table covers
  (observed: Excel creates the table and A2:B2 is no longer merged).
- Paste brings merged areas along, except into a table, where the cells arrive unmerged.

The command-sequence fuzzer checks the invariant (it found the paste case, seed 230).
2026-11-14 19:43:09 -06:00

34 lines
1.4 KiB
Rust

use gridcraft_core::{CellRef, Value};
use gridcraft_engine::Session;
use gridcraft_engine::calc::Calc;
use serde_json::{Value as Json, json};
fn run(s: &mut Session, command: &str, params: Json) {
s.execute(command, params).unwrap();
}
fn value(s: &Session, sheet: &str, cell: &str) -> Value {
let wb = &s.doc().unwrap().wb;
wb.sheet(wb.sheet_index(sheet).unwrap()).unwrap().value(CellRef::parse(cell).unwrap())
}
/// Issue #2053: the copy of a sheet holding a spill keeps the spill's values, in memory and after a full recalc.
#[test]
fn copied_sheet_keeps_spill_values_through_full_recalc() {
let mut s = Session::new();
run(&mut s, "file.new", json!({"sample": "grades"}));
run(&mut s, "home.mergeCells", json!({"range": "F15:H20"}));
run(&mut s, "cell.set", json!({"cell": "J54", "input": "=SEQUENCE(5)*C6"}));
run(&mut s, "selection.set", json!({"range": "15:15"}));
run(&mut s, "sheet.move", json!({"copy": true, "sheet": 0, "to": 1}));
run(&mut s, "cell.set", json!({"array": true, "cell": "D3", "input": "=SUM('Grades (2)'!J54#)"}));
let before = value(&s, "Grades (2)", "J55");
assert!(matches!(before, Value::Number(_)), "J55 should hold a spilled number, got {before:?}");
let mut fresh = (*s.doc().unwrap().wb).clone();
Calc::new().recalc_all(&mut fresh);
let after = fresh.sheet(fresh.sheet_index("Grades (2)").unwrap()).unwrap().value(CellRef::parse("J55").unwrap());
assert_eq!(before, after);
}