0

I've read a lot of where people have missing cell data due to null values but my issue is I have spreadsheets I'm parsing that have exactly 272 rows of data needing to be parsed. When I get the row count I'm only able to retrieve 269. Below is how I'm getting the row count.

// code above gets worksheet...
var rows = from row in worksheet.Descendants<Row>()
                             where row.RowIndex >= rowIndex
                             select row;

for (int i = 0; i <= rows.Count(); i++)
{
  // processing...
}

The rowIndex above is used because I'm only pulling 272 rows after a few heading rows and it needs to be dynamic as some sheets have multiple heading rows. Basically I search for a particular cell value for a string and then from there get the rowIndex and use that to get the row count.

I've tracked down the two rows not being picked up and do not have values in them, but there are other rows exactly the same that do not have values and the rows are included. It is important as all sheets I need to parse have 272 rows of specific data with blank rows in the same spot. One sheet will work fine and include the rows while another won't.

So I'm trying to determine why some blank rows are included but others are totally ignored like they do not exist.

Any help would be appreciated.

maguy
  • 1,599
  • 1
  • 15
  • 26
  • It might be helpful to use the Open Xml SDK 2.0 Productivity Tool to examine the actual xml of the rows that are problematic. – Steve Jun 07 '12 at 17:03

1 Answers1

0

The rows that don't have cells that have values should not be included as a rows in the total count. This makes sense since excel does not store row or cell information where the cell value is null.

The other rows that don't have any values in them but do show up most likely have a space in a cell somewhere. A space is a valid value for a cell and while it looks empty, it will be stored as a cell value and count towards the total number of rows.

amurra
  • 15,221
  • 4
  • 70
  • 87