date format when exporting to excel changes

1

I have this code to export to

asked by oscar ramirez 10.05.2017 в 17:32
source

2 answers

0

Use NumberFormat :

Example:

string FRM_EXCEL_FECHA = "dd/MM/yyyy"; // o el formato que deseas:
ws.Cells[i + 2, j + 1].NumberFormat = FRM_EXCEL_FECHA;
ws.Cells[i + 2, j + 1].Value = dataGridView2.Rows[i].Cells[j].Value.ToString();
    
answered by 10.05.2017 в 20:04
-1

Give that format to your column

Range rango = (Excel.Range)worksheetobject.Cells[1,1];
rango.EntireColumn.NumberFormat = "DD/MM/YYYY";
    
answered by 10.05.2017 в 20:00