0

I am using epplus and working on validating a spreadsheet. If any row/first column has no data then the row is invalid. I want to move to the next row. How do I test this first column in a row to make sure it is not empty? I know I have to use a break to get out of the loop.

            for (int i = start.Row; i <= end.Row; i++)
            {

                for (int j = start.Column; j <= end.Column; j++)
                {

                    //add the cell data to the list
                    if (String.IsNullOrEmpty(workSheet.Cells[i, j].Text.ToString()))
                        errors.Add($"Worksheet {workSheet.Name}, Row {i}, Column {j} does not contain data.");
                }
            }
Baba
  • 2,059
  • 8
  • 48
  • 81
  • Cells only contain references to cells with data. So if a row has no cells, then the row is empty. See here: https://stackoverflow.com/questions/52117722/epplus-find-if-the-entire-row-is-empty-in-excel – jscarle May 15 '20 at 15:44
  • What happens if the first column in a row is empty and the second column/other columns have data? That's what I am asking. – Baba May 15 '20 at 16:58
  • Then Cells will contain the additional columns of the row with data. – jscarle May 15 '20 at 18:54
  • So if that is the case, back to my question, how do you now check if the first row/column has data. If it does not have data skip the entire row and move to the next row. That first item in first row/first column is important to me and drives my transaction for that row. – Baba May 15 '20 at 19:09

0 Answers0