I have a Windows application that will export the value of DataGridView into an excel file. Exporting is ok, but the problem is that when it export the date which is in this format "yyyy-MM-dd HH:mm:ss", it is being replace by this format "MM/dd/yyyy HH:mm". My question is how to export the data on its original format?
Here is my code in writing the data on excel:
/*** Add the data from the grid to the sheet starting in row 2 ***/
for (i = 0; i < datagridview.RowCount - 1; i++)
{
for (c = 0; c < datagridview.ColumnCount; c++)
{
Parameters = new Object[2];
Parameters[0] = columns[c] + Convert.ToString(i + 2);
Parameters[1] = Missing.Value;
objRange_Late = objSheet_Late.GetType().InvokeMember("Range",
BindingFlags.GetProperty, null, objSheet_Late, Parameters);
Parameters = new Object[1];
Parameters[0] = datagridview.Rows[i].Cells[headers[c]].Value.ToString();
objRange_Late.GetType().InvokeMember("Value", BindingFlags.SetProperty,
null, objRange_Late, Parameters);
}
}
Thanks in advance.

New Topic/Question
Reply



MultiQuote





|