Do not use .ToString() it will cause null reference exception when the value is null. Use Convert.ToString(), it will return empty string for the null value. col1 = Convert.ToString(row.Cells[i + 1, 1].Value2); col2 = Convert.ToString(row.Cells[i + 1, 2].Value2);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter