diff --git a/crates/xlsx/src/write.rs b/crates/xlsx/src/write.rs index 9423d34a0e..c2ef8988f3 100644 --- a/crates/xlsx/src/write.rs +++ b/crates/xlsx/src/write.rs @@ -240,14 +240,18 @@ fn workbook_view_attrs(wb: &Workbook) -> String { /// Writes the workbook for the file `book_name` (a bare file name). A PivotChart is bound to its /// PivotTable in Excel only when its link starts with the workbook in brackets. -pub fn write_xlsx_named(wb: &Workbook, kind: XlsxKind, book_name: Option<&str>) -> Result, IoError> { +fn validate_xlsx_workbook(wb: &Workbook) -> Result<(), IoError> { if wb.sheets.is_empty() { return Err(IoError::Format("a workbook needs at least one sheet".into())); } if wb.sheets.iter().any(|sheet| sheet.cell_pictures.keys().any(|c| sheet.cell(*c).is_some_and(|cell| cell.formula.is_some()))) { return Err(IoError::Format("a static cell picture cannot also contain a formula".into())); } - check_sheet_names(wb)?; + check_sheet_names(wb) +} + +pub fn write_xlsx_named(wb: &Workbook, kind: XlsxKind, book_name: Option<&str>) -> Result, IoError> { + validate_xlsx_workbook(wb)?; let mut out = Out { parts: vec![], overrides: vec![],