473,405 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Exporting to Excel - Losing the first zero of zip code

3
I am exporting customer information from a MSSQL to an .xls using ASP. The exporting goes very well, all the info gets out ok except for the zip codes starting with zero (0), the data exports right (all five digits) but Excel represents the zip code as a "number" and it cuts off the first zero leaving the zip code with 4 numbers. I can always go to "format cell" , "special" , "zip code" and that will fix the problem but I am wondering if there's a way around this....

Mel
Aug 5 '06 #1
6 14549
sashi
1,754 Expert 1GB
Hi Mel,

how is your zip code stored in your SQL database? what is the datatype used?
Aug 5 '06 #2
melma
3
varchar 50 nullable
Aug 5 '06 #3
Banfa
9,065 Expert Mod 8TB
This is because EXCEL is treating the zip code as a number not as a string of digits. You can force EXCEL to treat it as a string by prepending a '

Expand|Select|Wrap|Line Numbers
  1. Data in SQL    Data in Excel
  2.     76235          '76235
  3.     93675          '93675
  4.     07352          '07352
  5.  
Aug 5 '06 #4
melma
3
That works but I would like to have a clean entry without the '
Aug 9 '06 #5
iam_clint
1,208 Expert 1GB
melma export it to something else then set your fields in excel to be string and not numeric because numericly the 0 is nothing so it removes it if you set the format to be string it should work fine when you move the data to it, i have had the same problem awhile back but i used the solution banfa just gave the ' before the number.
theres also a zipcode format in excel i am pretty sure that format would keep the preceeding 0's

if you read this banfa i think we need an excel topic somewhere.
Aug 9 '06 #6
That works but I would like to have a clean entry without the '
Why wouldn't a single quote make it a clean entry since you are entering text and not numbers. One thing you could try is to format the cells before you insert the zipcodes. If you select the column and click on Format > Cells > Number > Text, then the cell will be ready to accept numbers as text and shouldn't do anything to the input. Or you can even use the Format > Cells > Number > Special > Zip Code format.

One other possibility is to use a formula like =TEXT(B1,"000000"), so the number appears in the 5-digit zip format.

This is nice and all, but won't work for zip codes other than those in the US.
Jul 9 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
5
by: mik18 | last post by:
I'm having trouble with exporting reports to Word in the rtf format and I'm hoping someone has a solution. The reports are losing their formats. Not all the formating is lost but some is and of...
2
by: Regnab | last post by:
I've got my code working so that it'll count the number of columns in the table and move across (eg Range A-P and then range Q-W). Problem is when I get to the end of the single letters and get...
2
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
6
by: Kevin Humphreys | last post by:
Hi There, I am trying to export a recordset to an excel file using the Content Type below in the header. Response.ContentType = "application/vnd.ms-excel" Which works fine however the...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
6
by: Opa | last post by:
Hi, I have a DataGrid, whose sourceI am exporting to Excel. This works fine except for the Column ordering. My datasource is not a datatable, with a typical SELECT statement where I can...
2
by: RRoma | last post by:
Does anybody know how I can import lists of numbers from Excel into Access without losing the preceeding Zeros??? The field must have a total of 10 digits.... Is this a function of how its saved in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.