XLSB table calculations and custom styles
Existing table APIs with a finite binary profile
The TXLSXTable model writes and reads supported calculated-column definitions, built-in totals and custom table-style references via XLSB
These profiles use the existing workbook, table and CustomTableStyles APIs, and the general XLSB subset still determines which other workbook features are admitted
Calculated-column definitions
ColumnCalculatedColumnFormulas[Index] stores a table-column definition with a zero-based column index
The qualified formula subset admits ordinary local A1 cell references, finite numeric literals, parentheses, unary signs, addition, subtraction, multiplication, division, power and percent
For example, assign A2*B2 to the Amount column definition, or change it to (A2+B2)*2 to preserve the required evaluation order across binary persistence
This property changes definition metadata; it neither replaces nor populates every existing worksheet formula, and ordinary existing cells keep their separately stored formulas
Actual Excel controls add a table row without assigning its calculated cell formula, then verify that the definition generates the new formula and result; this tells a working table definition apart from prefilled result cells
Grouping acceptance also checks the visible native formula and assigning that formula text back to a cell, because correct cached values and RPN order on their own do not prove an editable formula keeps its meaning
Definitions are bounded to 8192 UTF-16 code units and 16384 token bytes; ranges, functions, names, structured references, cross-sheet or external references and arrays remain outside this calculated-column subset
Built-in totals and the owning worksheet cells
| ColumnTotalsRowFunctions value | Ordinary SUBTOTAL selector |
|---|---|
| none | No built-in total |
| average | 101 |
| count | 103, counting nonempty values |
| countNums | 102, counting numeric values |
| max | 104 |
| min | 105 |
| sum | 109 |
| stdDev | 107 |
| var | 110 |
When a real totals row exists, provide the matching ordinary worksheet SUBTOTAL formula for that table column's exact nonempty data region; for a SUM total at C5 over C2:C4, use SUBTOTAL(109,C2:C4)
The binary writer checks the supported selector and formula-token shape, owning column, data range and actual total-cell presence before it publishes output; inconsistent selectors, wrong ranges and missing formulas refuse
Hidden metadata with totalsRowCount=0 has no actual total-cell requirement; a count of 1 still requires validation even when totalsRowShown is false
The internal ownership map admits at most 32768 active built-in total cells per worksheet, carrying a conservative 512-byte metadata charge per owner; this is not a public whole-process memory limit
All eight positive built-in functions have library calculation and binary lifecycle controls; actual native representatives cover COUNTNUMS, AVERAGE and SUM rather than every combination of functions
Custom total formulas and structured PtgList references sit outside this profile
Custom table-style definitions
- Add a named style via Workbook.CustomTableStyles.Add and keep PivotStyle=false and TableStyleFlag=true for the binary worksheet profile
- Use SetSection on xltssWholeTable, xltssHeaderRow or xltssFirstRowStripe with supported explicit colours and font bold state
- Assign Table.StyleName to the owned definition and switch on ShowRowStripes when using the stripe section
- Save as XLSB, reopen and edit via the existing style or table-reference APIs
SetSection uses the existing opaque ARGB colour convention, such as $FFC0B0A0; zero retains its existing unset-colour meaning
The existing differential codec admits explicit opaque untinted RGB background fills, RGB font colours, bold and italic, including an explicit false italic state; the native font representative takes bold with italic false
Arbitrary theme/tinted differentials, borders and other table or Pivot style sections demand separate support
Names are nonempty and at most 255 UTF-16 code units, with unique case-insensitive identities; the collection admits at most 1024 definitions and one instance of every supported section per definition
Definition names also have to be legal XML text; invalid controls or unpaired surrogates lead to an explicit refusal on save
Literal Office escape-looking text such as _x000D_ stays part of the custom style name through XLSX and supported XLSB saving and reopening; the registered definition and its table references keep the same identity for FindByName lookups
The workbook properties DefaultTableStyleName and DefaultPivotStyleName store literal style names; Office escape-looking text such as _x000D_ remains literal through supported XLSX and XLSB metadata saving and reopening
For a custom table style, explicitly assign the registered name to each table's StyleName reference together with the workbook default selector; both hold the same registered definition identity
Custom Pivot-style definitions and their default selector metadata stay inside the existing XLSX profile; custom Pivot-style XLSB support is not added here
Default selector names have to be legal XML text; invalid controls or unpaired surrogates cause an explicit refusal for an ordinary XLSX save, with no guarantee that the destination stream stays unchanged
Stripe sizes keep the represented 1..9 range; style and element counts, schema namespaces, flags and differential references must match their actual owners
Custom table sections and ordinary conditional formats can share a differential pool whilst retaining separate, correctly rebased references; the combined collection remains limited to 4096 differential styles
The finite style admission has a 1 MiB metadata quota and separate preconstruction checks; this quota is no claim about total process or preflight peak memory
Persistence and actual execution
Qualified controls take in genuine native custom-style binary input, public style-reference and source-value edits, repeated binary saving, XML bridges and actual header, body and stripe display formatting in Excel
Final-source integration combines calculated columns, three built-in totals, custom styles and an independent conditional rule in a single workbook, including an edit to the existing imported header style
The final representative Win64 source passes 3113 focused checks using one cold build and 7 guarded reuses of the same source; this adds no new compiler or platform matrix
Checked XLSB output refusal retains the existing staged destination contract; a diagnostic or preserved part is not taken as successful calculation or formatting
Native source and conversion boundaries
An independently authored Excel table can contain structured PtgList worksheet formulas and table-column dataDxfId references even when its visible data looks ordinary; those records stay unsupported
The A1 calculated-definition bytes are independently matched to native records, but this does not qualify the opening of every complete native table workbook
Table-local row or column differential overrides, query-bound tables, XML mappings, sort state, unknown extension records and unrepresented style ownership stay explicitly refused
The broader Notes, conditional-format, filter, validation and rich-text profiles keep their own finite compatibility and appearance limits