Excel export for TanStack Table is a bit tricky thing, where the file has to keep the grouping instead of flattening it into a CSV. Some of it was less obvious than expected.
Totals should be formulas, but not SUM. Write the group totals as numbers and they go stale the moment someone edits a cell. SUM double counts when groups are nested, because the region total adds up country rows that are already totals. SUBTOTAL(9, ...) skips other SUBTOTAL cells, so nesting works. It also ignores rows that an Excel filter hides.
Grouping maps cleanly onto Excel outlines. row.depth becomes the outline level, so people get the little +/- buttons in Excel. Pinned columns map to frozen panes the same way. Both came down to reading the table state instead of the raw data.
Display columns are a trap. Columns without an accessor, like the checkbox column, the row menu or an avatar, end up in the file as empty columns. They now get skipped unless you opt in.
v9 broke my types in a way I didn't catch for a while.…