happysmile
happysmile

Reputation: 7777

Data not getting saved properly in excel file from stream writer


i am trying to write the date format data into an stream writer from where again am writing into an excel file

here i am changing the date format like this dd-MM-yyyy

StreamWriter strmWriteText= new
StreamWriter(); DateTime ldtPubmonth;
lstrmWriteText.Write(dsPubmonth.ToString("dd-MM-yyyy"));

but when ever data gets saved in the excel file the format is getting changed like this.

1/5/2010

actaully it should be like this 01-05-2010

is there any thing that i am going wrong like saving the data.

when i check the value in command window ?dsPubmonth.ToString("dd-MM-yyyy")); it shows the value 01-05-2010

i am using VS 2003, .net 1.1

thanks

Upvotes: 0

Views: 1398

Answers (1)

LaGrandMere
LaGrandMere

Reputation: 10359

You should maybe edit the Column format ?

Excel.Range rg = (Excel.Range)worksheetobject.Cells[1,1];
rg.EntireColumn.NumberFormat = "dd-MM-yyyy";

If it's just for a Cell, don't use EntireColumn.

Upvotes: 2

Related Questions