Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Stage: alpha** · next: beta, ~25 points of "ready for real work" and ~160–240 h away

> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-12 · **Change:** minor (rows auto-fit oversized fonts on open and whole-row/column formatting) · **Target:** Microsoft Excel (Microsoft 365)
> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-10-14 · **Change:** minor (GETPIVOTDATA and the PivotTable tabs) · **Target:** Microsoft Excel (Microsoft 365)

GridCraft aims at full Microsoft Excel parity, and at being better in places: faster, open (XLSX
is the native format), fully scriptable by agents (MCP, control channel, CLI), and on the web.
Expand All @@ -21,7 +21,7 @@ This page is the summary. The detail is in:

| Number | Value | Kind |
|---|---|---|
| **Feature breadth** (weighted) | **~75%** | estimated, anchored on two measurements: ribbon catalog 274 / 290 (94.5%), worksheet functions 513 / 523 (98.1%; 504 working, 96.4%) |
| **Feature breadth** (weighted) | **~75%** | estimated, anchored on two measurements: ribbon catalog 277 / 293 (94.5%), worksheet functions 514 / 523 (98.3%; 505 working, 96.6%) |
| **Ready for real work** | **~50%** | estimated from written weights (51.6); [target-app-parity.md](docs/target-app-parity.md) |
| **Mainstream practitioner** | **~50%** | estimated: typical analyst/finance user, weekly features, × 0.90 interaction × 0.92 stability × 0.88 file exchange; [method](docs/target-app-parity.md#mainstream-practitioner) |
| **Essentials user** | **~63%** | estimated: core features only, × 0.92 launch/stability × 0.95 clarity × 0.90 opening sent files; [method](docs/target-app-parity.md#essentials-user) |
Expand Down Expand Up @@ -132,6 +132,7 @@ Ranked; estimates in Opus 5.5 agent-hours. Detail and the full beta-gate list in

| Date | What landed |
|---|---|
| 2026-10-14 | PivotTables: GETPIVOTDATA (value field by caption or source field, row, column and report filter items, Excel's rules for totals and hidden items, recalculated on refresh, evaluated on open), Generate GetPivotData (clicking or arrowing onto a PivotTable value while typing a formula inserts it; on by default, also in File › Options › Formulas), and the PivotTable Analyze and Design contextual tabs in Excel 365's layout with German labels and key tips JT/JY |
| 2026-10-12 | Rows auto-fit oversized fonts: opening a file and whole-row/column formatting grow non-custom rows to their tallest font (#833) |
| 2026-10-12 | Number formats: parsing a format code is linear in its length (long runs of `[`, `,` or `/` no longer take quadratic time), and an unclosed `[` is a literal when splitting sections as well as when tokenizing (#810) |
| 2026-10-12 | Number formats: a fraction denominator with 65,536 zeros no longer crashes; format codes are capped at 255 characters like Excel (longer codes display as General, `TEXT` gives `#VALUE!`) (#807) |
Expand Down Expand Up @@ -193,6 +194,7 @@ Ranked; estimates in Opus 5.5 agent-hours. Detail and the full beta-gate list in

| Date | Change | Summary |
|---|---|---|
| 2026-10-14 | minor | Progress log row for GETPIVOTDATA and the PivotTable tabs |
| 2026-10-12 | minor | Rows auto-fit oversized fonts on open and whole-row/column formatting (#833); progress log row |
| 2026-10-12 | minor | Progress log: multi-area row/column delete (#758) |
| 2026-10-12 | trivial | Progress log: XLSX chart sheets kept on save (#727) |
Expand Down
80 changes: 80 additions & 0 deletions crates/calc/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub const MAX_CELLS: u64 = 16_000_000;
/// formulas over them stay fast.
const FULL_SIZE_CELLS: u64 = 16_384;
const MAX_DEPTH: usize = 400;
/// GETPIVOTDATA takes a value field, a PivotTable and up to 126 field/item pairs.
const MAX_GETPIVOTDATA_ARGS: usize = 254;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Area {
Expand Down Expand Up @@ -732,6 +734,7 @@ impl<'h> Evaluator<'h> {
"INDEX" => self.index(args),
"XLOOKUP" => self.xlookup(args),
"CELL" => self.cell_info(args),
"GETPIVOTDATA" => self.getpivotdata(args),
"TRIMRANGE" => self.trimrange(args),
"SUBTOTAL" | "AGGREGATE" => self.subtotal(name, args),
"TEXT" => {
Expand Down Expand Up @@ -1344,6 +1347,63 @@ impl<'h> Evaluator<'h> {
self.builtin("XLOOKUP", args)
}

/// GETPIVOTDATA(data_field, pivot_table, [field1, item1], …): a value shown in a PivotTable
/// report. `pivot_table` is any cell or range in the report; the report's index, written by
/// the engine with the report, says which cell the value field and items name
/// ([`gridcraft_model::PivotReport::lookup`]). An empty value cell counts as 0, as in Excel.
fn getpivotdata(&mut self, args: &[Expr]) -> Ev {
if args.len() < 2 || args.len() > MAX_GETPIVOTDATA_ARGS {
return err(CellError::Value);
}
let text = |v: Value| -> Result<String, CellError> { v.scalar().to_text() };
let data = match text(self.value(&args[0])) {
Ok(t) => t,
Err(e) => return err(e),
};
let area = match self.eval(&args[1]) {
Ev::R(areas) => match areas.first() {
Some(a) => *a,
None => return err(CellError::Ref),
},
Ev::V(Value::Error(e)) => return err(e),
_ => return err(CellError::Ref),
};
let mut pairs: Vec<(String, Value)> = Vec::with_capacity(args.len() / 2);
for pair in args.get(2..).unwrap_or_default().chunks(2) {
let field = match pair.first().map(|f| text(self.value(f))) {
Some(Ok(f)) => f,
Some(Err(e)) => return err(e),
None => return err(CellError::Ref),
};
// A field without its item names nothing.
let Some(item) = pair.get(1).map(|i| self.value(i).scalar()) else { return err(CellError::Ref) };
if let Value::Error(e) = item {
return err(e);
}
pairs.push((field, item));
}
let found = self.host.workbook().sheet(area.sheet).and_then(|sh| {
sh.pivots.iter().find_map(|p| {
let r = p.last_range.filter(|r| r.intersects(&area.range))?;
Some((r.start, p.report.0.clone()?))
})
});
let Some((origin, report)) = found else { return err(CellError::Ref) };
let named: Vec<(&str, &Value)> = pairs.iter().map(|(f, v)| (f.as_str(), v)).collect();
let (r, c) = match report.lookup(&data, &named) {
Ok(at) => at,
Err(e) => return err(e),
};
let (Some(row), Some(col)) = (origin.row.checked_add(r), origin.col.checked_add(c)) else { return err(CellError::Ref) };
if row >= MAX_ROWS || col >= MAX_COLS {
return err(CellError::Ref);
}
match self.host.cell_value(area.sheet, CellRef::new(row, col)) {
Value::Empty => Ev::V(Value::Number(0.0)),
v => Ev::V(v),
}
}

fn cell_info(&mut self, args: &[Expr]) -> Ev {
let kind = match self.arg_val(args, 0).map(|v| v.scalar().to_text()) {
Some(Ok(t)) => t.to_ascii_lowercase(),
Expand Down Expand Up @@ -1763,6 +1823,24 @@ pub fn precedents(wb: &Workbook, sheet: usize, e: &Expr) -> (Vec<Area>, bool) {
(_, Some(Expr::Number(_) | Expr::Text(_) | Expr::Bool(_) | Expr::Error(_) | Expr::Array(_) | Expr::Missing)) => {}
_ => dynamic = true,
},
// GETPIVOTDATA reads a cell of the report its reference points into. Refreshing a
// PivotTable recalculates everything; an edit inside the report must reach it too.
Expr::Call(n, args) if n == "GETPIVOTDATA" => {
if let Some(Expr::Ref(r)) = args.get(1) {
let range = r.range();
let mut reports = Vec::new();
push(&mut reports, r, range);
for a in reports {
let hits = wb
.sheet(a.sheet)
.into_iter()
.flat_map(|sh| sh.pivots.iter())
.filter_map(|p| p.last_range)
.filter(|pr| pr.intersects(&a.range));
out.extend(hits.map(|range| Area { sheet: a.sheet, range }));
}
}
}
Expr::Call(n, _)
if matches!(n.as_str(), "INDIRECT" | "OFFSET" | "NOW" | "TODAY" | "RAND" | "RANDBETWEEN" | "RANDARRAY" | "CELL" | "INFO") =>
{
Expand Down Expand Up @@ -1811,6 +1889,7 @@ fn is_special(n: &str) -> bool {
| "INDIRECT"
| "INDEX"
| "CELL"
| "GETPIVOTDATA"
| "TRIMRANGE"
| "SUBTOTAL"
| "AGGREGATE"
Expand Down Expand Up @@ -1849,6 +1928,7 @@ pub const SPECIAL_FUNCTIONS: &[&str] = &[
"INDIRECT",
"INDEX",
"CELL",
"GETPIVOTDATA",
"TRIMRANGE",
"SUBTOTAL",
"AGGREGATE",
Expand Down
43 changes: 43 additions & 0 deletions crates/calc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1266,3 +1266,46 @@ fn offset_extreme_arguments_return_ref() {
assert_eq!(crate::evaluate(&wb, 0, c("D1"), formula), Value::Number(expected), "{formula}");
}
}

#[test]
fn getpivotdata_reads_the_report_index() {
use gridcraft_model::{PivotReport, PivotReportIndex, PivotTable, ReportDataField, ReportField, ReportItem, ReportKey};
// A report at D1:E4 as the engine writes it: a header, East and West, a grand total.
let mut t = T::new();
let item = |l: &str| ReportItem { value: Value::text(l), label: l.into() };
let key = |offset, items: &[Option<u32>]| ReportKey { offset, data: None, items: items.to_vec() };
let report = PivotReport {
data_fields: vec![ReportDataField { name: "Sum of Sales".into(), source: "Sales".into() }],
row_fields: vec![ReportField { name: "Region".into(), dates: false, items: vec![item("East"), item("West")] }],
rows: vec![key(1, &[Some(0)]), key(2, &[Some(1)]), key(3, &[None])],
cols: vec![ReportKey { offset: 1, data: Some(0), items: vec![] }],
label_cols: 1,
compact: true,
..PivotReport::default()
};
let pt = PivotTable {
anchor: c("D1"),
last_range: Some(gridcraft_core::RangeRef::parse("D1:E4").unwrap()),
report: PivotReportIndex(Some(std::sync::Arc::new(report))),
..PivotTable::default()
};
t.wb.sheet_mut(0).unwrap().pivots.push(pt);
for (at, v) in [("E2", "30"), ("E3", "12"), ("E4", "42")] {
t.set(at, v);
}
t.set("A1", r#"=GETPIVOTDATA("Sales",D1,"Region","west")"#);
t.set("A2", r#"=GETPIVOTDATA("Sum of Sales",E4)"#);
t.set("A3", r#"=GETPIVOTDATA("Sales",D1,"Region","North")"#);
assert_eq!(t.num("A1"), 12.0);
assert_eq!(t.num("A2"), 42.0);
assert_eq!(t.get("A3"), Value::Error(CellError::Ref));
// A changed report cell reaches the formulas that read it.
t.set("E3", "13");
assert_eq!(t.num("A1"), 13.0);
// An empty value cell reads as 0; without an index there is nothing to read.
t.set("E3", "");
assert_eq!(t.num("A1"), 0.0);
t.wb.sheet_mut(0).unwrap().pivots[0].report = PivotReportIndex::default();
t.set("A1", r#"=GETPIVOTDATA("Sales",D1,"Region","West")"#);
assert_eq!(t.get("A1"), Value::Error(CellError::Ref));
}
5 changes: 4 additions & 1 deletion crates/engine/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ pub const CATALOG: &[(&str, &str, &str, &str)] = &[
("chart.shapeFill", "Format", "Shape Styles", "Shape Fill"),
("chart.shapeOutline", "Format", "Shape Styles", "Shape Outline"),
// PivotTable Analyze / Design
("pivot.generateGetPivotData", "PivotTable Analyze", "PivotTable", "Generate GetPivotData"),
("pivot.fieldList", "PivotTable Analyze", "Show", "Field List"),
("pivot.refresh", "PivotTable Analyze", "Data", "Refresh"),
("pivot.changeSource", "PivotTable Analyze", "Data", "Change Data Source"),
Expand All @@ -316,7 +317,9 @@ pub const CATALOG: &[(&str, &str, &str, &str)] = &[
("pivot.sort", "PivotTable Analyze", "Sort", "Sort"),
("pivot.group", "PivotTable Analyze", "Group", "Group Field"),
("pivot.collapse", "PivotTable Analyze", "Active Field", "Collapse Field"),
("pivot.delete", "PivotTable Analyze", "Actions", "Clear All"),
("pivot.clearAll", "PivotTable Analyze", "Actions", "Clear All"),
("pivot.clearFilters", "PivotTable Analyze", "Actions", "Clear Filters"),
("pivot.delete", "PivotTable Analyze", "Actions", "Delete PivotTable"),
];

/// Distinct catalog ids.
Expand Down
6 changes: 6 additions & 0 deletions crates/engine/src/cmd/formulas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ pub fn function_list() -> Vec<Json> {
("ISREF", "Information", "ISREF(value)", "TRUE for references."),
("ISFORMULA", "Information", "ISFORMULA(reference)", "TRUE when the cell has a formula."),
("FORMULATEXT", "Lookup", "FORMULATEXT(reference)", "The formula of a cell as text."),
(
"GETPIVOTDATA",
"Lookup",
"GETPIVOTDATA(data_field, pivot_table, [field1, item1], ...)",
"Returns a value shown in a PivotTable report, named by its value field and items.",
),
("SHEET", "Information", "SHEET([value])", "Sheet number."),
("SHEETS", "Information", "SHEETS([reference])", "Number of sheets."),
("AREAS", "Lookup", "AREAS(reference)", "Number of areas in a reference."),
Expand Down
89 changes: 89 additions & 0 deletions crates/engine/src/cmd/pivot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,28 @@ pub fn specs() -> Vec<CommandSpec> {
has_doc,
delete
),
cmd!(query "pivot.generateGetPivotData", "Generate GetPivotData", ["PivotTable Analyze", "PivotTable", "Options"], None, "{on?: bool} (toggles without it) → {on}: pointing at a PivotTable value while typing a formula inserts GETPIVOTDATA (an application setting, on by default)", always, |s, p| {
s.prefs.generate_get_pivot_data = bool_param(p, "on").unwrap_or(!s.prefs.generate_get_pivot_data);
Ok(json!({"on": s.prefs.generate_get_pivot_data}))
}),
cmd!(
"pivot.clearAll",
"Clear All",
["PivotTable Analyze", "Actions", "Clear"],
None,
"{pivot?, replace?} takes every field out of Rows, Columns, Values and Filters (the PivotTable stays, empty; calculated fields and layout options are kept)",
has_doc,
clear_all
),
cmd!(
"pivot.clearFilters",
"Clear Filters",
["PivotTable Analyze", "Actions", "Clear"],
None,
"{pivot?, replace?} shows every item again: report filters go back to (All) and hidden items of row and column fields come back",
has_doc,
clear_filters
),
]
}

Expand Down Expand Up @@ -1377,6 +1399,33 @@ fn delete(s: &mut Session, p: &Json) -> Result<Json> {
})
}

/// PivotTable Analyze › Clear › Clear All: an empty PivotTable on the same source, as Excel
/// leaves it. Calculated fields are definitions rather than layout, so they stay available.
fn clear_all(s: &mut Session, p: &Json) -> Result<Json> {
update(s, p, |pt, _, _| {
pt.rows.clear();
pt.columns.clear();
pt.values.clear();
pt.filters.clear();
pt.values_on_rows = false;
pt.values_position = None;
Ok(json!({}))
})
}

/// PivotTable Analyze › Clear › Clear Filters: report filters show (All) again and row and
/// column fields lose their hidden-items filters.
fn clear_filters(s: &mut Session, p: &Json) -> Result<Json> {
update(s, p, |pt, _, _| {
let axes: Vec<String> = pt.rows.iter().chain(pt.columns.iter()).map(|f| f.source_col.to_ascii_lowercase()).collect();
pt.filters.retain(|f| !axes.contains(&f.source_col.to_ascii_lowercase()));
for f in &mut pt.filters {
f.selected = None;
}
Ok(json!({}))
})
}

// ---------------------------------------------------------------- PivotChart

/// The PivotTable a PivotChart call targets: `pivot` may also be a cell of its report.
Expand Down Expand Up @@ -2308,4 +2357,44 @@ mod tests {
// 64 Sub items under the collapsed "g" show as one column group: (1 + grand total) x 256 columns fit.
s.execute("pivot.addField", json!({"field": "Sub", "area": "columns"})).unwrap();
}

#[test]
fn generate_getpivotdata_is_a_setting_on_by_default() {
let mut s = Session::new();
assert!(s.prefs.generate_get_pivot_data);
assert_eq!(s.execute("pivot.generateGetPivotData", json!({})).unwrap()["on"], false);
assert_eq!(s.execute("pivot.generateGetPivotData", json!({"on": true})).unwrap()["on"], true);
assert!(s.journal.is_empty(), "a setting, not an edit of the workbook");
// A prefs.json saved before the setting existed keeps it on.
let old: crate::Prefs = serde_json::from_str(r#"{"userName": "Ann"}"#).unwrap();
assert!(old.generate_get_pivot_data);
}

#[test]
fn clear_all_leaves_an_empty_pivottable_and_clear_filters_shows_every_item() {
let mut s = sales();
s.execute("insert.pivotTable", json!({"rows": ["Region", "Product"], "values": ["Sales"], "filters": ["Date"]})).unwrap();
s.execute("pivot.filter", json!({"field": "Product", "selected": ["Apples"]})).unwrap();
s.execute("pivot.filter", json!({"field": "Date", "selected": ["1/15/2026"]})).unwrap();
let p = pt(&s);
assert_eq!(p.filters.len(), 2);
s.execute("pivot.clearFilters", json!({})).unwrap();
let p = pt(&s);
// The report filter stays, showing (All); the row field's hidden items are gone.
assert_eq!(p.filters.len(), 1);
assert_eq!(p.filters[0].source_col, "Date");
assert_eq!(p.filters[0].selected, None);
let gt = find_row(&s, "Grand Total").unwrap();
assert_eq!(val(&s, &CellRef::new(gt, 1).a1()), Value::Number(TOTAL));
// Clear All keeps the PivotTable, now empty, and is one undo step.
s.execute("pivot.calculatedField", json!({"name": "Tax", "formula": "=Sales*0.1", "values": false})).unwrap();
s.execute("pivot.clearAll", json!({})).unwrap();
let p = pt(&s);
assert!(p.rows.is_empty() && p.columns.is_empty() && p.values.is_empty() && p.filters.is_empty());
assert_eq!(p.calculated_fields.len(), 1);
assert!(text(&s, "A3").starts_with("PivotTable1"), "{}", text(&s, "A3"));
assert_eq!(s.doc().unwrap().wb.active().unwrap().pivots.len(), 1);
s.execute("edit.undo", json!({})).unwrap();
assert_eq!(pt(&s).rows.len(), 2);
}
}
7 changes: 7 additions & 0 deletions crates/engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const UNDO_LIMIT: usize = 100;

impl DocState {
pub fn new(mut wb: Workbook, path: Option<String>, title: String) -> DocState {
// GETPIVOTDATA reads the reports of PivotTables that came with the file.
pivot::index_reports(&mut wb);
let mut calc = Calc::new();
calc.recalc_all(&mut wb);
let wb = Arc::new(wb);
Expand Down Expand Up @@ -199,6 +201,10 @@ pub struct Prefs {
pub user_dictionary: Vec<String>,
/// View › Show › Formula Bar (an application option in Excel, not saved in the file).
pub formula_bar: bool,
/// PivotTable Analyze › Options › Generate GetPivotData (File › Options › Formulas › Use
/// GetPivotData functions for PivotTable references): pointing at a value of a PivotTable
/// while typing a formula inserts GETPIVOTDATA instead of the cell's reference.
pub generate_get_pivot_data: bool,
}

impl Default for Prefs {
Expand All @@ -213,6 +219,7 @@ impl Default for Prefs {
r1c1: false,
user_dictionary: vec![],
formula_bar: true,
generate_get_pivot_data: true,
}
}
}
Expand Down
Loading