Skip to content

Commit 03b7050

Browse files
committed
Test for #261
1 parent 7fb2ba9 commit 03b7050

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

tests/issue_261.xlsx

15.6 KB
Binary file not shown.

tests/issue_261_fixed_by_excel.xlsx

20.8 KB
Binary file not shown.

tests/test.rs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,76 @@ fn issue_252() {
913913
assert!(open_workbook::<Xls<_>, _>(&path).is_err());
914914
}
915915

916+
#[test]
917+
fn issue_261() {
918+
setup();
919+
920+
let mut workbook_with_missing_r_attributes = {
921+
let path = format!("{}/tests/issue_261.xlsx", env!("CARGO_MANIFEST_DIR"));
922+
open_workbook::<Xlsx<_>, _>(&path).unwrap()
923+
};
924+
925+
let mut workbook_fixed_by_excel = {
926+
let path = format!(
927+
"{}/tests/issue_261_fixed_by_excel.xlsx",
928+
env!("CARGO_MANIFEST_DIR")
929+
);
930+
open_workbook::<Xlsx<_>, _>(&path).unwrap()
931+
};
932+
933+
let range_a = workbook_fixed_by_excel
934+
.worksheet_range("Some Sheet")
935+
.unwrap()
936+
.unwrap();
937+
938+
let range_b = workbook_with_missing_r_attributes
939+
.worksheet_range("Some Sheet")
940+
.unwrap()
941+
.unwrap();
942+
943+
assert_eq!(range_a.cells().count(), 462);
944+
assert_eq!(range_a.cells().count(), 462);
945+
assert_eq!(range_a.rows().count(), 66);
946+
assert_eq!(range_b.rows().count(), 66);
947+
948+
assert_eq!(
949+
range_b.get_value((0, 0)).unwrap(),
950+
&String("String Value 32".into())
951+
);
952+
range_b
953+
.rows()
954+
.nth(4)
955+
.unwrap()
956+
.iter()
957+
.for_each(|cell| assert!(cell.is_empty()));
958+
959+
assert_eq!(range_b.get_value((60, 6)).unwrap(), &Float(939.));
960+
assert_eq!(
961+
range_b.get_value((65, 0)).unwrap(),
962+
&String("String Value 42".into())
963+
);
964+
965+
assert_eq!(
966+
range_b.get_value((65, 3)).unwrap(),
967+
&String("String Value 8".into())
968+
);
969+
970+
range_a
971+
.rows()
972+
.zip(range_b.rows().filter(|r| !r.is_empty()))
973+
.enumerate()
974+
.for_each(|(i, (lhs, rhs))| {
975+
assert_eq!(
976+
lhs,
977+
rhs,
978+
"Expected row {} to be {:?}, but found {:?}",
979+
i + 1,
980+
lhs,
981+
rhs
982+
)
983+
});
984+
}
985+
916986
#[test]
917987
fn test_values_xls() {
918988
let path = format!(

0 commit comments

Comments
 (0)