Hi,
i wonder if anyone can help me, i am exporting a datagridview to excel using sample code i received. the datagridview shows all rows correctly, but when i export to excel and check in excel there is data missing , any help will be appreciated as i am not sure what i am missing or doing wrong
string excel_file = directoryFinance;
int cols;
StreamWriter wr = new StreamWriter(excel_file);
cols = dataGridView1.Columns.Count;
for (int i = 0; i < cols; i++)
{
wr.Write(dataGridView1.Columns[i].Name.ToString().ToUpper() + "\t");
}
wr.WriteLine();
for (int i = 0; i < (dataGridView1.Rows.Count - 1); i++)
{
for (int j = 0; j < cols; j++)
{
if (dataGridView1.Rows[i].Cells[j].Value != null)
wr.Write(dataGridView1.Rows[i].Cells[j].Value + "\t");
else
{
wr.Write("\t");
}
}
wr.WriteLine();
}
wr.Close();
Thank you
Kallie