This project has moved. For the latest updates, please go here.

Row by row shows varying lengths in C#

Sep 19, 2013 at 2:01 PM

My application is reading an excel sheet from an external vendor. The excel sheet looks fine, but it appears that it was edited using some feature in excel which confuses my epplus based code.

This two consecutive code lines returns two different numbers (on the same excel sheet).
since they cover the same amount of columns, the numbers should be the same, AFAICT.

Question 1: What can cause this? Merged cells? Cells with "null" content? Special content types (eg Formulas)?
Question 2: How do I compensate? I discovered this because .ElementAt() started returning the wrong stuff. It is very important that I am reading the visual column.
Question 3: I assume that some cells are missing. If this, for example, is "f280", what will happen if I try to access it directly.

Thank you.
Sep 20, 2013 at 7:32 PM
I've never needed to take a look inside it, but I think only initialized cells will be in dictionary, if you try to access it directly will create a new entry on cell´s dictionary. So, If I am right, you can have a lot of "roles" inside your cells collection. Why you need to use ElementAt? Maybe you can try a linq querie.