Skip to content

Commit

Permalink
fix bug where empty rows made Excel writer crash
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed May 10, 2022
1 parent b70044a commit 6d12edf
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/FsSpreadsheet.ExcelIO/FsExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ module FsExtensions =
self.GetRows()
|> List.iter (fun row ->
let cells = row.Cells(self.CellCollection) |> Seq.toList
let min,max =
cells
|> List.map (fun cell -> uint32 cell.WorksheetColumn)
|> fun l -> List.min l, List.max l
let cells =
cells
|> List.map (fun cell ->
Cell.fromValue None (uint32 cell.WorksheetColumn) (uint32 cell.WorksheetRow) (cell.Value)
)
let row = Row.create (uint32 row.Index) (Row.Spans.fromBoundaries min max) cells
SheetData.appendRow row sd |> ignore
if not cells.IsEmpty then
let min,max =
cells
|> List.map (fun cell -> uint32 cell.WorksheetColumn)
|> fun l -> List.min l, List.max l
let cells =
cells
|> List.map (fun cell ->
Cell.fromValue None (uint32 cell.WorksheetColumn) (uint32 cell.WorksheetRow) (cell.Value)
)
let row = Row.create (uint32 row.Index) (Row.Spans.fromBoundaries min max) cells
SheetData.appendRow row sd |> ignore
)
sd
Worksheet.setSheetData sheetData sheet
Expand Down

0 comments on commit 6d12edf

Please sign in to comment.