ExcelProvider icon indicating copy to clipboard operation
ExcelProvider copied to clipboard

Empty rows after data get read anyway

Open zelite opened this issue 8 years ago • 3 comments

Description

I have an excel file with five rows (including headers). When reading it with the ExcelProvider, I get one extra empty row. Is this the expected behavior?

Repro steps

  1. Get the excel file

  2. Run the following FSharp script:

#r @"..\packages\ExcelProvider.0.8.1\lib\ExcelProvider.dll"

open FSharp.ExcelProvider

[<Literal>]
let excelFilePath = "TestBook.xlsx"

type ExcelWorkbook = ExcelFile<excelFilePath>

let source = new ExcelWorkbook()

source.Data 
    |> Seq.iter (fun row -> printfn "%A" row)

Expected behavior

I expected the data to only include the rows with actual data on them.

Actual behavior

When printing the rows, I see one extra row which is empty.

Related information

  • Windows 7 (x64)
  • Excel Provider 0.8.1

zelite avatar May 09 '17 08:05 zelite

I'm dealing with this bug everytime I use this library. Is this behaviour consistent as it seems? Is there any reason to not cut the last row?

gmlion avatar Dec 09 '21 14:12 gmlion

HI. This seems to be consistent behavior, I am also getting it. I haven't looked in the code as yet to try and see what causes it. The only reason not to remove it is that it may be a breaking change for users who have written code depending on this quirk. It would be interesting to hear from other users how they would want this to be addressed.

quintusm avatar Dec 09 '21 14:12 quintusm

I would expect this bug to be fixed as a breaking change (and appropriately noted in the release notes).

Currently, I'm doing a quick and dirty work around like this:

    type File = ExcelFile<DefaultFilePath>

    let file = File filePath
    let count = file.Data |> Seq.length

    file.Data
    |> Seq.truncate(count - 1)

irfancharania avatar Dec 09 '21 18:12 irfancharania