Hi,
In the given line of code from where you are getting error,
i.e.
xlWorkSheetData.Cells[i + 2, j + 1] = dgvPopulateData.Rows[i].Cells[j].Value.ToString();
the possibility i can see for the error message is either
.Value
or
.ToString()
. You need checking for Null value of
dgvPopulateData.Rows[i].Cells[j]
check if HashValue method available if so , use it to check if data is available. or you can simply check for Null.
So you code would be like,
if(dgvPopulateData.Rows[i].Cells[j] != null)
{
xlWorkSheetData.Cells[i + 2, j + 1] = dgvPopulateData.Rows[i].Cells[j].Value.ToString();
}
Hope this will resolve your issue,
Thanks
-Amit Gajjar.