Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/xlsb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ impl<RS: Read + Seek> Xlsb<RS> {
Some("worksheets") => SheetType::WorkSheet,
Some("chartsheets") => SheetType::ChartSheet,
Some("dialogsheets") => SheetType::DialogSheet,
// Excel 4.0 macro sheets and international macro
// sheets.
Some("macrosheets") => SheetType::MacroSheet,
_ => {
return Err(XlsbError::Unrecognized {
typ: "BoundSheet8:dt",
Expand Down
2 changes: 2 additions & 0 deletions src/xlsx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ impl<RS: Read + Seek> Xlsx<RS> {
Some("worksheet") => SheetType::WorkSheet,
Some("chartsheet") => SheetType::ChartSheet,
Some("dialogsheet") => SheetType::DialogSheet,
// Excel 4.0 macro sheets and international macro sheets.
Some("xlMacrosheet" | "xlIntlMacrosheet") => SheetType::MacroSheet,
_ => {
return Err(XlsxError::Unrecognized {
typ: "sheet:type",
Expand Down
Binary file added tests/macro_sheets.xls
Binary file not shown.
Binary file added tests/macro_sheets.xlsb
Binary file not shown.
Binary file added tests/macro_sheets.xlsm
Binary file not shown.
45 changes: 45 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2457,6 +2457,51 @@ fn test_ods_sheets_metadata() {
);
}

#[rstest]
#[case("macro_sheets.xlsm")]
#[case("macro_sheets.xlsb")]
#[case("macro_sheets.xls")]
fn test_all_macro_sheets(#[case] test_file: &str) {
// Test that Excel 4.0 macro sheets and international macro sheets are read
// as macro sheets, along with their cells and formulas. The files are the
// same workbook saved by Excel in each format. See issue #802.
let mut workbook = open_workbook_auto(test_path(test_file)).unwrap();

assert_eq!(
workbook.sheets_metadata(),
&[
Sheet {
name: "Data".to_string(),
typ: SheetType::WorkSheet,
visible: SheetVisible::Visible
},
Sheet {
name: "Macro1".to_string(),
typ: SheetType::MacroSheet,
visible: SheetVisible::Visible
},
Sheet {
name: "Intl1".to_string(),
typ: SheetType::MacroSheet,
visible: SheetVisible::Visible
},
]
);

let range = workbook.worksheet_range("Macro1").unwrap();
range_eq!(range, [[Bool(false)], [Bool(false)]]);
let formulas = workbook.worksheet_formula("Macro1").unwrap();
range_eq!(
formulas,
[["ECHO(FALSE)".to_string()], ["RETURN()".to_string()]]
);

let range = workbook.worksheet_range("Intl1").unwrap();
range_eq!(range, [[Bool(false)]]);
let formulas = workbook.worksheet_formula("Intl1").unwrap();
range_eq!(formulas, [["RETURN()".to_string()]]);
}

#[test]
fn test_xlsx_password_protected() {
// Test that a password protected xlsx file returns XlsxError::Password.
Expand Down