Preserve t="str" on empty-string formula results - #357
Merged
MathNya merged 1 commit intoAug 25, 2026
Conversation
The cell reader only handled a self-closing `<v/>` for formulas, so an empty cached string result (written by Excel/LibreOffice as `<v/>`) was dropped and the cell decayed to Empty, losing its `t="str"` type on write. Handle `<v/>` in the `Event::Empty` arm, dispatching on the declared type so an empty string result stays a string. Bump version to 3.1.1. Closes MathNya#356
ben-schreiber
force-pushed
the
fix/empty-string-formula-result-type
branch
from
August 24, 2026 10:54
3457482 to
90ad410
Compare
Owner
|
@ben-schreiber |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #356.
Problem
When the reader encounters a formula cell whose cached result is an empty string — written by Excel/LibreOffice as a self-closing
<v/>witht="str"— the value is dropped and the cell decays toEmpty, losing its string type. On write thet="str"attribute disappears, so=IF(cond,"","x")evaluating to""becomes an untyped/blank cell. Non-empty string results are unaffected.Root cause: in
Cell::set_attributes, theEvent::Startarm dispatches<v>on the declaredttype, but theEvent::Emptyarm (which is how a self-closing<v/>arrives) only handled<f/>and ignored<v/>entirely.Fix
Handle
<v/>in theEvent::Emptyarm, dispatching on the declared type the same way theEvent::Startarm does, so an empty string result keepst="str".Repro (before this PR)
input.xlsxcell:<c r="A1" t="str"><f>IF(TRUE,"","x")</f><v/></c>After the fix the written cell keeps its type:
<c r="A1" t="str"><f>IF(TRUE,"","x")</f><v></v></c>.Tests
Added
empty_string_formula_result_keeps_str_typecovering the read path. Fullcargo test --libpasses (114 tests).