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.
Syncfusion Feedback

Numerical string keeps dropping zeros

Thread ID:

Created:

Updated:

Platform:

Replies:

54576 Jan 11,2007 11:15 AM Jan 12,2007 08:12 AM ASP.NET Web Forms (Classic) 1
loading
Tags: XlsIO
Ryan
Asked On January 11, 2007 11:15 AM

I have a column of postal codes that I'm setting up as a string since many postal codes will contain leading zeros(i.e. "04438", "00110") however when my xls sheet opens, it eliminates the leading zeros (i.e. "4438", "110").

I'm trying to set this by first populating the spreadsheet with the data and then formatting the column:
-------------------------------------------
sheet.ImportArray(data,1,1);
sheet.Columns[0].HorizontalAlignment = ExcelHAlign.HAlignCenter;
sheet.Columns[0].ColumnWidth = 11;
sheet.Columns[0].NumberFormat = "@";
---------------------------------------------

I would think that by using "@" as the numberFormat, that would prevent the leading zeros from dropping however that doesn't seem to be the case.

Any idea on what I should do?

Thanks.

-Ryan

Melba Winshia [Syncfusion]
Replied On January 12, 2007 08:12 AM

Hi Ryan,

Could you please try using the following code snippets to set the postal codes with the leading zeros?

[C#]

//Number format to preserve the leading zeros
sheet.Range["A1:A2"].NumberFormat="00000";

//Import array of objects
sheet.ImportArray( arrInt, 1, 1, true );

Here is the sample for your reference:

ImportArrayBoder.zip

Please take a look at the sample above and let me know if you have any other questions.

Best Regards,
Melba

CONFIRMATION

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.

Warning Icon 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.Close Icon

;