How to change dd/mm/yyyy date formate of excel to dd-mm-yyyy

Mar 17 2020 4:43 AM
Date in my data table is in 1-3-2020 this format . I am saving this date in excel file  by using following code
 
for (int j = 0; j < CopyDataTable.Rows.Count; j++)
{
for (int k = 0; k < CopyDataTable.Columns.Count; k++)
{
if (k == 7 || k == 10)
{
if (CopyDataTable.Rows[j].ItemArray[k].ToString().Contains("-"))
{
xlWorkSheet.Range[xlWorkSheet.Cells[j + 2, k + 1], xlWorkSheet.Cells[j + 2, k + 1]].NumberFormat
= "dd-mm-yyyy";
}
try
{
xlWorkSheet.Cells[j + 2, k + 1] = CopyDataTable.Rows[j].ItemArray[k].ToString();
}
catch (Exception ex)
{ }
}
xlWorkSheet.Cells[j + 2, k + 1] = CopyDataTable.Rows[j].ItemArray[k].ToString();
}
}
 
but it is displaying as 03-01-2020  in excel and i want to display as 01-03-2020 . Please provide solution for it.
 

Answers (1)