We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Format string with zero's?

Hi, im trying to format a string like 000055555 in a excel sheet. But its is imposible, the excel generated show the string as number like this.

555555

My code is this, 

        sheet.Columns[10].CellStyle.NumberFormat = "@";

thankss

Carlos
                


1 Reply

PK Prakash Kumar D Syncfusion Team July 2, 2014 10:58 AM UTC

Hi Carlos,

 

We suspect this as a usage issue. You might have used Value or Value2 property instead of Text property. Value or Value2 property converts the data type as per value in the cell. In your scenario, number “00005555” is trying to store as text initially and the number format is applied. So, the value is already converted to number while assigning, and the cell type is changes to Text later. We recommend to use the Text property in order to get the issue resolved. We have attached the code snippet for your reference.

 

Code Snippet:

 


sheet["A1"].Text = "000055555";

sheet.Columns[0].CellStyle.NumberFormat = "@";

              

 

Regards,

Prakash


Loader.
Up arrow icon