Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2005
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Leading Zeros stripped

    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!!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Put ="00001" as the cell value.

  • #3
    New Coder
    Join Date
    Oct 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    MyString.PadLeft(5, "0"n);
    or
    i think it's
    myvariable = string.format( " number is {-5:N}", thenumber );

    -john


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •