diff --git a/crates/textimport/src/xlsx.rs b/crates/textimport/src/xlsx.rs index f27c305f0..f49bdd220 100644 --- a/crates/textimport/src/xlsx.rs +++ b/crates/textimport/src/xlsx.rs @@ -39,8 +39,9 @@ fn sheet_cells( let result = package.sheet(entry, |row| { for cell in row.cells { let value = match cell.value { - // Retain legacy display of non-finite spellings such as `inf`. - craft_xlsx::CellValue::Invalid(raw) => raw.parse::().map(general).unwrap_or_default(), + // A value that doesn't read as its type says (`inf`, `n/a` in a number cell) is + // shown as written, as the importer did before the shared reader. + craft_xlsx::CellValue::Invalid(raw) => raw, value => display(value.resolve(&strings, date_1904)), }; text_bytes = text_bytes.saturating_add(value.len()); @@ -419,6 +420,15 @@ mod tests { } } + #[test] + fn number_cells_that_are_not_numbers_show_as_written() { + for text in ["inf", "Infinity", "NaN", "n/a", "12 apples"] { + let book = one_value(&format!(r#"{text}"#)); + let rows = crate::xlsx_records(&book, None).unwrap(); + assert_eq!(rows[1][0], text, "cell {text}"); + } + } + #[test] fn cached_string_values_are_not_reformatted_as_numbers() { for text in ["00123", "1e3", "12.0", " 42 "] {