You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(xls): a formula kept as its saved value loses a text result (394 cells in one POI file) #802
Some formulas can't be represented by the .xls reader: references to other workbooks, a reference to a missing name, What-If data tables. For these it keeps the saved result as a value and warns "Some formulas use …; their saved results were kept as values." That works for numbers, booleans and errors. A text result is lost: the cell comes out empty unless it has a cell format of its own.
Observed
Excel 365 shows the text in every case below; GridCraft (main fc45b7f, also with #464 merged) shows the cell empty.
How I counted: for each FORMULA record with a string result, I read the text from the STRING record that follows and compared it with what GridCraft shows (gridcraft-cli cat --csv). I did this for every .xls in Apache POI's test data and in Damodaran's spreadsheets (426 files; two that GridCraft can't open were skipped). The table lists every file where text was lost. Cells of array and shared formulas are fine because they are recalculated.
Root cause
formula_cell (crates/xlsx/src/xls/mod.rs:736) stores the cell with an empty value until the STRING record arrives.
Cells::set (crates/model/src/store.rs:50) drops a cell that is blank (empty value, no formula, default style).
A formula that is attached gets its cell back in attach. A formula kept as a value doesn't, so the STRING handler (mod.rs:600, cells.get_mut(pos)) finds no cell and drops the text.
A cell with a non-default XF isn't blank, which is why some text results in the same files survive.
Suggested fix
Have the STRING handler create the cell when it is missing: keep the cell's style with pending_string and set the text. Test with a BIFF8 sheet holding a FORMULA record whose formula is kept as a value (for example an external reference), with a string result and the default XF, followed by its STRING record.
Activity
XLS: a formula kept as its saved value keeps a text result (fixes sto…