Skip to content

Commit

Permalink
add fail for writing empty workbook
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Feb 12, 2024
1 parent 6cc4d8d commit 4eaf806
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/FsSpreadsheet.ExcelIO/FsExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,10 @@ module FsExtensions =
/// Writes the FsWorkbook into a given MemoryStream.
/// </summary>
member self.ToStream(stream : MemoryStream) =
if self.GetWorksheets() |> Seq.isEmpty then
failwith "Cannot write an empty workbook to a stream. Workbook did not contain any Worksheets."
let doc = Spreadsheet.initEmptyOnStream stream

self.ToEmptySpreadsheet(doc)
//Worksheet.setSheetData sheetData sheet |> ignore
//WorkbookPart.appendWorksheet worksheet.Name sheet workbookPart |> ignore
Expand Down

0 comments on commit 4eaf806

Please sign in to comment.