system.nullreferenceexception 未将对象引用设置到对象的实例。

DataGridView 导出时出现的问题。

可能grid行的单元的没有值。

------------------------------------------------------------------------------

if (dataGridview1.Rows[j].Cells[k].Value != null)
{
          tempStr += dataGridview1.Rows[j].Cells[k].Value.ToString();
}

原文地址:https://www.cnblogs.com/ok519/p/1561815.html