Hi,
I am extracting data from datagridview to Excel. But for columns with so many numbers Excel turns the format to 6,45646E+11
Is there a way that I can prevent this.
I tried to use worksheets but I could not even save the data by using that.
Here is my code:
int i = 1;
int j;
foreach (DataRow row in datatable.Rows)
{
j = 1;
foreach (DataColumn col in datatable.Columns)
{
ExcelApp.Cells[i, j] = row[col.ColumnName].ToString();
j = j + 1;
}
i = i + 1;
}
ExcelApp.ActiveWorkbook.SaveAs(filename, Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
ExcelApp.ActiveWorkbook.Saved = true;
ExcelApp.Quit();