string format getting changed in excel
string StrDat开发者_如何学Pythone= Convert.ToDateTime(Datset.Tables[0].Rows[i][j]).ToString(@"dd-MM-yyyy").Trim(); string StrDateNew=StrDate.ToString(); strmWriteText.Write(StrDateNew.ToString());
when i write the data to excel file the string format is getting chaged into dd/mm/yyyy
is there any way i can solve this problem i am using excel 2000,vs 2003
any help would great thanks
you need to deal with the Range.NumberFormat property while you write the data to Excel.
e.g. the following line where format myWorkSheet
column 1 to "dd-MM-yyyy":
myWorkSheet.get_Range(myWorkSheet.Cells[1,1],myWorkSheet.Cells[Datset.Tables[0].Rows.Count+1,1]).NumberFormat="dd-mm-yyyy";
精彩评论