MarkPflug/Sylvan.Data.Excel

Exception when trying to create reader with XLS file

Closed this issue · 6 comments

xnmf commented

I am trying to read this file:
https://sample-videos.com/xls/Sample-Spreadsheet-50000-rows.xls

I then get the following exception when trying to create the reader as follow: ExcelDataReader.Create(filepath, options)

Exception:

System.ArgumentException: 'Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.'

[Exception] mscorlib.dll!System.IO.FileStream.Read(byte[] array, int offset, int count)	Unknown

[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.Ole2Package.Ole2Stream.Read(byte[] buffer, int offset, int count) Line 256 C#
[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.Xls.XlsWorkbookReader.RecordReader.FillBuffer(int required) Line 64 C#
[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.Xls.XlsWorkbookReader.RecordReader.NextRecord() Line 236 C#
[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.Xls.XlsWorkbookReader.ReadHeader() Line 386 C#
[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.Xls.XlsWorkbookReader.XlsWorkbookReader(System.IO.Stream stream, Sylvan.Data.Excel.ExcelDataReaderOptions options) Line 304 C#
[Exception] Sylvan.Data.Excel.dll!Sylvan.Data.Excel.ExcelDataReader.Create(System.IO.Stream stream, Sylvan.Data.Excel.ExcelWorkbookType fileType, Sylvan.Data.Excel.ExcelDataReaderOptions options) Line 324 C#
Sylvan.Data.Excel.dll!Sylvan.Data.Excel.ExcelDataReader.Create(string filename, Sylvan.Data.Excel.ExcelDataReaderOptions options) Line 317 C#

I am also facing the same issue,
any update on this?

image

Enhanced AP.xls

I have a fix implemented for this. It resolves the issue when reading the file ankitsataparaTR provided. However, the xnmf provided encounters a subsequent issue that I'm still trying to figure out.

This issue is now fixed with v 0.4.24, which I just published to nuget. This fixes the issue with both files.

Thank you very much @MarkPflug for the quick fix.
Really appreciated :) 👍

@MarkPflug
The error we are getting earlier is now gone but I am facing below issue with the same attached file in the previous thread.
Can you please help us on that?

image

On newer .NET versions you need to explicitly register the 1252 provider:

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

This needs to be called once during startup of the application.