Skip to content

Commit

Permalink
actually check if path is empty instead of just defaulting
Browse files Browse the repository at this point in the history
  • Loading branch information
tzilist committed Mar 20, 2024
1 parent 8514334 commit 3d8c7e2
Showing 1 changed file with 20 additions and 23 deletions.
43 changes: 20 additions & 23 deletions src/xlsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,30 +376,27 @@ impl<RS: Read + Seek> Xlsx<RS> {
_ => (),
}
}
let typ = match path.split('/').nth(1) {
Some("worksheets") => SheetType::WorkSheet,
Some("chartsheets") => SheetType::ChartSheet,
Some("dialogsheets") => SheetType::DialogSheet,
_ => {
// NOTE(ted): Calamine, by default, sends an error.
// Sometimes our customers send malformatted excel files to use.
// We can just ignore this and try and default to WorkSheet.
// Leaving this code here in case we want to rever thsi later.
//
// return Err(XlsxError::Unrecognized {
// typ: "sheet:type",
// val: path.to_string(),
// })
if !path.is_empty() {
let typ = match path.split('/').nth(1) {
Some("worksheets") => SheetType::WorkSheet,
Some("chartsheets") => SheetType::ChartSheet,
Some("dialogsheets") => SheetType::DialogSheet,
_ => {
return Err(XlsxError::Unrecognized {
typ: "sheet:type",
val: path.to_string(),
})
}
};

SheetType::WorkSheet
}
};
self.metadata.sheets.push(Sheet {
name: name.to_string(),
typ,
visible,
});
self.sheets.push((name, path));
self.metadata.sheets.push(Sheet {
name: name.to_string(),
typ,
visible,
});

self.sheets.push((name, path));
}
}
Ok(Event::Start(ref e)) if e.name().as_ref() == b"workbookPr" => {
self.is_1904 = match e.try_get_attribute("date1904")? {
Expand Down

0 comments on commit 3d8c7e2

Please sign in to comment.