Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

Commented Unassigned: Error loading file [11818]

$
0
0
I'm trying to read the attached file. I'm getting the following error.

xlDataSet = xlReader.AsDataSet();
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

The file appears to be valid, when I open the file in excel and save it again the same code works without a problem.
Comments: ** Comment from web user: saccoder **

I faced the same error so i included those 4 lines:

First:
```
if ((uint) m_offset >= bytes.Length)
return null;
```
Secound:
```
if ((uint)offset >= bytes.Length)
return null;
```

```

/// <summary>
/// Reads record under cursor and advances cursor position to next record
/// </summary>
/// <returns></returns>
[MethodImpl(MethodImplOptions.Synchronized)]
public XlsBiffRecord Read()
{
if ((uint) m_offset >= bytes.Length)
return null;
XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)m_offset);
m_offset += rec.Size;
if (m_offset > m_size)
return null;
return rec;
}

/// <summary>
/// Reads record at specified offset, does not change cursor position
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
public XlsBiffRecord ReadAt(int offset)
{
if ((uint)offset >= bytes.Length)
return null;
XlsBiffRecord rec = XlsBiffRecord.GetRecord(bytes, (uint)offset);
if (m_offset + rec.Size > m_size)
return null;
return rec;
}
```

it temporaly solved the error...


Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>