Solved

coldfusion, How to enter zipcodes into an excel spreadsheet without having the leading zero being dropped. Is it possible to change the category of the column in coldfusion?

Posted on 2008-10-06
3
560 Views
Last Modified: 2013-12-16
I'm using coldfusion to create an excel spreadsheet. How do I enter zipcodes into that spreadsheet without having the leading zero being dropped. Is it possible to change the category of the column from number to zip code or text in coldfusion?

To get around this I was entering " " before the zip code to allow for the leading zero to be displayed; however, the end user doesn't like the space being there. So I need to find another way to enter a zip with the leading zero still there.
0
Comment
Question by:FalveyCF
3 Comments
 
LVL 36

Accepted Solution

by:
SidFishes earned 250 total points
ID: 22651402
when you do the export use mso-number-format for text

ie:

<cfheader name="Content-Disposition" value="filename=test.xls">
<cfcontent type="application/vnd.ms-excel">
<table>
<tr><td style="mso-number-format:\@">
010101
</td></tr>
</table>
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 22651627
Hello FalveyCF,

SidFishes gave you an excellent alternative, which basically uses number formatting to force Excel to treat
the value as text (an thus retain leading zeroes).  Another way would have been to prepend a single-quote
to the zip code, which again forces Excel to treat the entry as text.

If you want to keep the entry as a number but still *display* leading zeroes, the format string in Excel would
be:
[<10000]00000;[>=10000]00000-0000

That keeps the entries as numbers, but displays a traditional zip code or zip+4.  No idea how to pass that
format string in ColdFusion, though...

Regards,

Patrick
0
 

Author Closing Comment

by:FalveyCF
ID: 31503436
Thank you very much! It worked perfectly!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now