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

Formatting Numbers as Text

Many of our account numbers have leading zeros. I'd like to be able to format the account number column as text so that 001 shows up in the spreadsheet as 001 and not 1. This is particularly helpful if the user adds new account numbers to the spreadsheet after it is created. Essentially the same thing as right clicking on a column in Excel, select "Format Cells" and then selecting Text from the Categories list. I cannot find anywhere in the documentation or examples that will allow me to do this.

Thanks


2 Replies

YG Yavanaarasi G Syncfusion Team July 11, 2008 11:05 AM UTC

Hi Todd,

Thank you for your interest in Syncfusion products.

You can format the cell as text by using NumberFormat. For leading Zeros you have to set the format as "00#". Please refer the below code snippet:


[C#]
sheet.Range["A1"].Number = 0001;
sheet.Range["A1"].NumberFormat = "00#";



Here is the sample for your reference:
http://websamples.syncfusion.com//samples/XlsIO.Windows/XlsIO_Cell_format/main.htm

Please try this and let me know if this helps.

Regards,
G.Yavana







JC JUAN CASTILLO February 19, 2018 09:48 PM UTC

ok

Loader.
Live Chat Icon For mobile
Up arrow icon