Skip to content

Retain style-only cells by default (skipStyledEmptyCells to opt out) - #84

Merged
borgar merged 5 commits into
borgar:masterfrom
steinnes:keep-styled-empty-cells
Jul 7, 2026
Merged

Retain style-only cells by default (skipStyledEmptyCells to opt out)#84
borgar merged 5 commits into
borgar:masterfrom
steinnes:keep-styled-empty-cells

Conversation

@steinnes

@steinnes steinnes commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What

Cells that carry a style but no value, formula, or data table (e.g. <c r="C2" s="1"/>, a blank cell pre-formatted with a date number format) are now retained on import. A new skipStyledEmptyCells option (default false) drops them.

Why

handlerCell's empty-cell check silently dropped such cells, losing the number format on import. Keeping them preserves the format so it survives when a value or formula is later written into the cell.

How

  • Style-only cells are emitted with their style attached and no v/f/dt.
  • skipStyledEmptyCells drops them again, unless the style has visible formatting (fill, border, etc.).
  • Cells with a value/formula, and fully blank cells with no style, are unchanged.

steinnes added 2 commits July 1, 2026 22:32
Cells that carry only a style/number-format but no value or formula
(e.g. <c r="C2" s="1"/>, a blank cell pre-formatted with a date
number format) were silently dropped by handlerCell's empty-cell
check, losing the number format on import.

keepStyledEmptyCells (default off, preserving current behavior) opts
into emitting these cells with their style attached and no v/f/dt, so
downstream consumers can preserve the intended format when later
writing a value or formula into the cell.
…ells

Invert the earlier keepStyledEmptyCells opt-in: style-only cells (a style
but no value/formula/data table) are now kept on import by default so the
number format is preserved. skipStyledEmptyCells opts back into dropping
them, unless the style has visible formatting such as a fill or border.
@steinnes steinnes changed the title Add keepStyledEmptyCells option to retain style-only cells Retain style-only cells by default (skipStyledEmptyCells to opt out) Jul 6, 2026
@steinnes
steinnes marked this pull request as ready for review July 6, 2026 15:06
@borgar
borgar merged commit 0145af4 into borgar:master Jul 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants