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 through XLSB
These profiles use the existing workbook, table and CustomTableStyles APIs; the general XLSB subset still determines which other workbook features are admitted
Calculated-column definitions
ColumnCalculatedColumnFormulas[Index] stores a table-column definition using a zero-based column index
The qualified formula subset uses 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 through binary persistence
This property changes definition metadata; it does not replace or populate 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 distinguishes a working table definition 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 alone do not prove an editable formula retains its meaning
Definitions are limited 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, supply 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 publishing output; inconsistent selectors, wrong ranges and missing formulas refuse
Hidden metadata with totalsRowCount=0 has no actual total-cell requirement; a count of 1 requires validation even when totalsRowShown is false
The internal ownership map admits at most 32768 active built-in total cells per worksheet, with 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 function combination
Custom total formulas and structured PtgList references remain outside this profile
Custom table-style definitions
- Add a named style through 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 colors and font bold state
- Assign Table.StyleName to the owned definition and enable ShowRowStripes when using the stripe section
- Save as XLSB, reopen and edit through the existing style or table-reference APIs
SetSection uses the existing opaque ARGB color convention, such as $FFC0B0A0; zero retains its existing unset-color meaning
The existing differential codec admits explicit opaque untinted RGB background fills, RGB font colors, bold and italic, including an explicit false italic state; the native font representative uses bold with italic false
Arbitrary theme/tinted differentials, borders and other table or Pivot style sections require 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 each supported section per definition
Definition names must also be legal XML text; invalid controls or unpaired surrogates cause an explicit save refusal
Literal Office escape-looking text such as _x000D_ remains part of the custom style name through XLSX and supported XLSB saving and reopening; the registered definition and its table references retain 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 and the workbook default selector; both retain the same registered definition identity
Custom Pivot-style definitions and their default selector metadata remain within the existing XLSX profile; this does not add custom Pivot-style XLSB support
Default selector names must be legal XML text; invalid controls or unpaired surrogates cause an explicit ordinary XLSX save refusal, which does not guarantee an unchanged destination stream
Stripe sizes use 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 while 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 not a claim about total process or preflight peak memory
Persistence and actual execution
Qualified controls cover 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 one 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 same-source reuses; 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 treated 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 remain unsupported
The A1 calculated-definition bytes are independently matched to native records, but this does not qualify opening 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 retain explicit refusal
The broader Notes, conditional-format, filter, validation and rich-text profiles retain their own finite compatibility and appearance limits