PDA

View Full Version : Leading Zeros stripped



JayM
Nov 14th, 2005, 07:39 PM
Hello all,

In my .NET app, I have a segement of code that translates the contents of a DataGrid to an Excel file. I've tried all the variants of System.Text.Encoding however when I have a text string like "00001", Excel displays it as "1".

Is there any Encoding I can do in .NET to maintain the leading zeros?

Thanks!!

glenngv
Nov 15th, 2005, 02:42 AM
Put ="00001" as the cell value.

kampfer
Nov 15th, 2005, 01:50 PM
MyString.PadLeft(5, "0"n);
or
i think it's
myvariable = string.format( " number is {-5:N}", thenumber );

-john