Skip to content

Commit

Permalink
Merge pull request #349 from jqnatividad/formula_empty_string_value
Browse files Browse the repository at this point in the history
Formula empty string value handling
  • Loading branch information
tafia authored Sep 4, 2023
2 parents a54bd9c + 18b332e commit c860397
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/xls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,9 +1314,12 @@ fn parse_formula(
/// FormulaValue [MS-XLS 2.5.133]
fn parse_formula_value(r: &[u8]) -> Result<Option<DataType>, XlsError> {
match *r {
[0x00, .., 0xFF, 0xFF] => Ok(None), // String, value should be in next record
// String, value should be in next record
[0x00, .., 0xFF, 0xFF] => Ok(None),
[0x01, _, b, .., 0xFF, 0xFF] => Ok(Some(DataType::Bool(b != 0))),
[0x02, _, e, .., 0xFF, 0xFF] => parse_err(e).map(Some),
// ignore, return blank string value
[0x03, _, .., 0xFF, 0xFF] => Ok(Some(DataType::String("".to_string()))),
[e, .., 0xFF, 0xFF] => Err(XlsError::Unrecognized {
typ: "error",
val: e,
Expand Down
Binary file added tests/issue343.xls
Binary file not shown.
10 changes: 10 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,16 @@ fn issue281_vba() {
);
}

#[test]
fn issue343() {
setup();

let path = format!("{}/tests/issue343.xls", env!("CARGO_MANIFEST_DIR"));

// should not panic
let _: Xls<_> = open_workbook(&path).unwrap();
}

#[test]
fn any_sheets_xlsx() {
setup();
Expand Down

0 comments on commit c860397

Please sign in to comment.