diff --git a/src/lib.rs b/src/lib.rs index 4ec74eb..9a0e527 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -217,21 +217,16 @@ pub struct Sheet { /// Row to use as header /// By default, the first non-empty row is used as header -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Default, Clone, Copy)] #[non_exhaustive] pub enum HeaderRow { /// First non-empty row + #[default] FirstNonEmptyRow, /// Index of the header row Row(u32), } -impl Default for HeaderRow { - fn default() -> Self { - HeaderRow::FirstNonEmptyRow - } -} - // FIXME `Reader` must only be seek `Seek` for `Xls::xls`. Because of the present API this limits // the kinds of readers (other) data in formats can be read from. /// A trait to share spreadsheets reader functions across different `FileType`s diff --git a/src/xlsx/cells_reader.rs b/src/xlsx/cells_reader.rs index 53d80a0..4c907ff 100644 --- a/src/xlsx/cells_reader.rs +++ b/src/xlsx/cells_reader.rs @@ -359,17 +359,8 @@ fn read_v<'s>( Ok(DataRef::DateTimeIso(v)) } Some(b"str") => { - // see http://officeopenxml.com/SScontentOverview.php - // str - refers to formula cells - // * indicates calculated value (this case) - // * to the formula string (ignored case - // TODO: Fully support a Data::Formula representing both Formula string & - // last calculated value? - // - // NB: the result of a formula may not be a numeric value (=A3&" "&A4). - // We do try an initial parse as Float for utility, but fall back to a string - // representation if that fails - v.parse().map(DataRef::Float).or(Ok(DataRef::String(v))) + // string + Ok(DataRef::String(v)) } Some(b"n") => { // n - number diff --git a/tests/string-ref.xlsx b/tests/string-ref.xlsx new file mode 100644 index 0000000..780d83c Binary files /dev/null and b/tests/string-ref.xlsx differ diff --git a/tests/test.rs b/tests/test.rs index b74d89e..4faf6b7 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -2125,3 +2125,16 @@ fn test_no_header(#[case] header_row: HeaderRow, #[case] expected: &[[Data; 2]]) .unwrap(); range_eq!(range, expected); } + +#[test] +fn test_string_ref() { + let mut xlsx: Xlsx<_> = wb("string-ref.xlsx"); + let expected_range = [ + [String("col1".to_string())], + [String("-8086931554011838357".to_string())], + ]; + // first sheet + range_eq!(xlsx.worksheet_range_at(0).unwrap().unwrap(), expected_range); + // second sheet is the same with a cell reference to the first sheet + range_eq!(xlsx.worksheet_range_at(1).unwrap().unwrap(), expected_range); +}