Dim Row As Integer = 13
For i = 0 To grdvwInterestBreakdown.RowCount - 2
For j = 0 To grdvwInterestBreakdown.ColumnCount - 1
xlworksheet.Cells(Row, j + 1) = grdvwInterestBreakdown(j, i).Value.ToString()
Next
Row = Row + 1
Next
grdvwInterestBreakdown.RowCount - 1
- Returns the last row which has no value.
When you have 20 rows in the gridview, two of the last row is null that is why it returns this error:
Object reference not set to an instance of an object