Going mad >> Index was out of range



I’ve been stuck with this problem a couple of hours now - It popped out of the blue, which means that it previously worked flawlessly, but suddenly stopped doing so and now I’m stuck. The error is:

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

The line that causes the error is this:

xlCell.Style.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin

When this happens I’m looping through a collection in ASP.NET - I do this more places than this, but this is the only place it fails. There’s two fixes to this at the moment:

1) I don’t do any looping around printing this cell with PutValue OR
2) I remove the cell style

Either of these is acceptable, but currently I’m just wasting time, because I’m getting nowhere and can’t pin-point what’s causing the error.



Hi Daniel,

Could you send me your code by email or post here? I will investigate what caused your problem.

Or you can have a live meeting with me at http://www.aspose.com/Corporate/Teams/Nanjing/Contactus.html.