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.
Unfortunately, activation email could not send to your email. Please try again.

Formatting Numbers as Text

Thread ID:





75074 Jul 10,2008 07:18 PM Feb 19,2018 04:48 PM Windows Forms 2
Tags: XlsIO
Administrator [Syncfusion]
Asked On July 10, 2008 07:18 PM

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.


Yavanaarasi G [Syncfusion]
Replied On July 11, 2008 07:05 AM

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:

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

Here is the sample for your reference:

Please try this and let me know if this helps.


Replied On February 19, 2018 04:48 PM



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.