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

Zeros left in a column

Hi.
I am trying to put in a column text with leading zeroes "0041123", and applying NumberFormat = "@" to the column it is formated as Text, but no zeros appear. Only "41123".

What do I have to apply to NumberFormat for zeros to appear?

Greetings.



3 Replies

AV Abirami Varadharajan Syncfusion Team March 16, 2017 07:40 AM UTC

Hi Juan, 
 
Thank you for contacting Syncfuison support. 
 
Kindly try below code to preserve the number preceding with 0’s as text.  
 
Code Example: 
            sheet.Range["A1"].Text = "0041123"; 
            sheet.Range["A1"].NumberFormat = "@"; 
            sheet.Range["A1"].IgnoreErrorOptions = ExcelIgnoreError.NumberAsText; 
 
Please let us know if you have any concerns. 
 
Regards, 
Abirami 



JU Juan March 16, 2017 08:27 AM UTC

Thank you very much for the quick response.
I got it working by modifying the data import:


worksheet.ImportDataTable(Datos, True, 1, 1, True)

I did not know the "IgnoreErrorOptions" option.

Thank you.



AV Abirami Varadharajan Syncfusion Team March 17, 2017 07:25 AM UTC

Hi Juan, 
 
Thank you for updating us. 
 
We are glad that the issue is resolved at your end. Please let us know if you need any further assistance. 
 
Regards, 
Abirami. 


Loader.
Up arrow icon