Repository navigation
Keep the type of a cached formula result through a save - #8
Merged
Merged
Conversation
A formula cell read from a file with t="str", t="b", t="e" or t="d" kept its cached <v> but not the type, so a save wrote <v>hello</v> with no t attribute. OOXML reads such a cell as numeric, and other readers reject the file (openpyxl: could not convert string to float: 'hello'). The shared cell decoder now carries the cell's t into the formula's cached-result type, which the writer already emits; recalculate() set that type the same way. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Problem. A formula cell read from a file as
t="str",t="b",t="e"(or
t="d") keeps its cached<v>but not its type, so a read-and-save turnsinto a cell with no
tand<v>hello</v>. OOXML reads an untyped cell asnumeric, so other consumers reject the file: openpyxl
load_workbook(..., data_only=True)raisesValueError: could not convert string to float: 'hello', and an error cachefails on
'#DIV/0!'; a boolean cache silently becomes the number 1. Thelibrary's own reader accepts the malformed cell, which is why a same-library
round trip does not show it.
Fix. The shared cell decoder (used by the eager and the streaming reader)
now carries the cell's
tinto the formula's cached-result type, the wayrecalculate()already does; the writer already emitted that type._cachedTypeCodelearns'd'for ISO-date caches. The public constructor'snumeric-cache behavior is documented and unchanged; this fix does not infer
a type for a caller-supplied string.
Validation.
test/formula_test.dart: four typed cases save withtheir
tand re-read with the same formula and cached value, plus a streamedcell re-inserted through
updateCell. All fail before, pass after.Independent check: the saved text and error workbooks that openpyxl refused
now load with
data_only=Trueand yield'hello'(types) and'#DIV/0!'(type
e). LibreOffice also opens and re-saves both workbooks, with thecached results confirmed afterward. Full suite and analyzer clean.
🤖 Generated with Claude Code