开发者

string format getting changed in excel

开发者 https://www.devze.com 2023-01-31 18:27 出处:网络
string StrDat开发者_如何学Pythone= Convert.ToDateTime(Datset.Tables[0].Rows[i][j]).ToString(@\"dd-MM-yyyy\").Trim();

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";
0

精彩评论

暂无评论...
验证码 换一张
取 消