fsprojects / ExcelProvider

This library is for the .NET platform implementing a Excel type provider.
http://fsprojects.github.io/ExcelProvider/
The Unlicense
140 stars 49 forks source link

Empty rows after data get read anyway #41

Open zelite opened 7 years ago

zelite commented 7 years ago

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

gmlion commented 2 years ago

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?

quintusm commented 2 years ago

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.

irfancharania commented 2 years ago

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)