ExcelDataReader
ExcelDataReader copied to clipboard
ExcelReaderFactory.CreateReader throws ArgumentOutOfRangeException
In some files, ExcelReaderFactory.CreateReader throws ArgumentOutOfRangeException.
Exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: startIndex
Stacktrace:
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.BitConverter.ToUInt32(Byte[] value, Int32 startIndex)
at ExcelDataReader.Core.BinaryFormat.XlsBiffDimensions..ctor(Byte[] bytes, UInt32 offset, Int32 biffVersion) in C:\projects\exceldatareader\src\ExcelDataReader\Core\BinaryFormat\XlsBiffDimensions.cs:line 17
at ExcelDataReader.Core.BinaryFormat.XlsBiffStream.GetRecord(Stream stream) in C:\projects\exceldatareader\src\ExcelDataReader\Core\BinaryFormat\XlsBiffStream.cs:line 221
at ExcelDataReader.Core.BinaryFormat.XlsBiffStream.Read() in C:\projects\exceldatareader\src\ExcelDataReader\Core\BinaryFormat\XlsBiffStream.cs:line 124
at ExcelDataReader.Core.BinaryFormat.XlsWorksheet.ReadWorksheetGlobals() in C:\projects\exceldatareader\src\ExcelDataReader\Core\BinaryFormat\XlsWorksheet.cs:line 587
at ExcelDataReader.Core.BinaryFormat.XlsWorkbook.<ReadWorksheets>d__66.MoveNext() in C:\projects\exceldatareader\src\ExcelDataReader\Core\BinaryFormat\XlsWorkbook.cs:line 137
at ExcelDataReader.ExcelDataReader`2.<ReadWorksheetsWithCache>d__77.MoveNext() in C:\projects\exceldatareader\src\ExcelDataReader\ExcelDataReader.cs:line 285
at ExcelDataReader.ExcelDataReader`2.Reset() in C:\projects\exceldatareader\src\ExcelDataReader\ExcelDataReader.cs:line 178
at ExcelDataReader.ExcelReaderFactory.CreateReader(Stream fileStream, ExcelReaderConfiguration configuration) in C:\projects\exceldatareader\src\ExcelDataReader\ExcelReaderFactory.cs:line 47
at NovusOptra.Core.RulesetManipulation.DataExtractors.MultiColumnDataExtractors.XlsMultiColumnDataExtractor.LoadDataUsingExcelDataReader(String filePath) in D:\Projects\NovusOptra\NovusOptra.Core.Wpf\RulesetManipulation\DataExtractors\MultiColumnDataExtractors\XlsMultiColumnDataExtractor.cs:line 51
The issue is very random and happens with only select xls files. Such an excel file is: https://gofile.io/?c=0EjbAZ
Any help will be highly appreciated.
Regards, Yogesh
The file link doesn't work. Please provide the sample file again.
Needs more info
I was searching for a solution to this error and found that I myself posted this error here but did not follow it.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')
at System.BitConverter.ToInt16(Byte[] value, Int32 startIndex)
at System.BitConverter.ToUInt16(Byte[] value, Int32 startIndex)
at ExcelDataReader.Core.BinaryFormat.XlsBiffRecord.ReadUInt16(Int32 offset)
at ExcelDataReader.Core.BinaryFormat.XlsBiffDimensions..ctor(Byte[] bytes, UInt32 offset, Int32 biffVersion)
at ExcelDataReader.Core.BinaryFormat.XlsBiffStream.GetRecord(Stream stream)
at ExcelDataReader.Core.BinaryFormat.XlsBiffStream.Read()
at ExcelDataReader.Core.BinaryFormat.XlsWorksheet.ReadWorksheetGlobals()
at ExcelDataReader.Core.BinaryFormat.XlsWorksheet..ctor(XlsWorkbook workbook, XlsBiffBoundSheet refSheet, Stream stream)
at ExcelDataReader.Core.BinaryFormat.XlsWorkbook.ReadWorksheets()+MoveNext()
at ExcelDataReader.ExcelDataReader`2.ReadWorksheetsWithCache()+MoveNext()
at ExcelDataReader.ExcelDataReader`2.Reset()
at ExcelDataReader.ExcelBinaryReader..ctor(Stream stream, String password, Encoding fallbackEncoding)
at ExcelDataReader.ExcelReaderFactory.CreateReader(Stream fileStream, ExcelReaderConfiguration configuration)
2023-07-MED-1003605-000000.Xls Attached the file for reference.
@appel1 Hello John. Can you please reopen this. Thanks & Regards. Yogesh.
@yjagota What version of ExcelDataReader did you test with? I can't reproduce your error with 3.7.0-develop00385.