Steve,

Are the zip codes you are working with fixed length, or is the pad length (number of zeros on the front) fixed?

If you can generate an html file for Excel then CSS can be applied to tell Excel to treat the numbers correctly. If you want to stay away from styles, then <td x:str="'001">001</td> will force the Excel parser to treat the cell as if '001 had been entered manually.

I know that I'm suggesting HTML as the internal format of the file when you are using CSV, but if you target is Excel and you want to preserve leading zeros into Excel, this is one way to do it.

Regards,

Jason.

PS: Tip o' the hat to Scott Cadillac for coming up with the original that this example is based on.


<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<style>
table
{
mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";
}
.zip_fixed_length
{
mso-number-format:"000-000";
}
.zip_fixed_pad
{
mso-number-format:'"000"#';
}
</style>
</head>
<body>
<table border="1">
<thead><tr><th>Zip</th></tr></thead>
<tbody>
<td x:str="'001">001</td>
<tr><td class="zip_fixed_length">0877</td></tr>
<tr><td class="zip_fixed_length">012877</td></tr>
<tr><td class="zip_fixed_length">958877</td></tr>
<tr><td class="zip_fixed_length">1958877</td></tr>
<tr><td class="zip_fixed_length">NSW</td></tr>
<tr><td class="zip_fixed_pad">0877</td></tr>
<tr><td class="zip_fixed_pad">012877</td></tr>
<tr><td class="zip_fixed_pad">958877</td></tr>
<tr><td class="zip_fixed_pad">1958877</td></tr>
<tr><td class="zip_fixed_pad">NSW</td></tr>
</tbody>
</table>
</body>
</html>

On 06/05/2005, at 3:18 AM, Fogelson, Steve wrote:

I am writing an array into a csv file with the following:
 
<@var request$Labels aprefix="" asuffix="" rprefix="" rsuffix="<@crlf>" cprefix="" csuffix=",">
 
Everything works great except when I open it with excel, it removes leading zeros for zip codes. Evidently it thinks it is a numeric field. If you open the csv file with NotePad, it is fine.
 
Any suggestions how to handle this?
 
Thanks
 
Steve Fogelson
Internet Commerce Solutions
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

<x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>WITH IMAGINATION
</x-tad-bigger>
<x-tad-bigger>Planning, Implementation and Management of Web Applications
</x-tad-bigger>
<x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>160 Pacific Highway North Sydney NSW Australia 2060</x-tad-bigger><x-tad-bigger>
</x-tad-bigger>
<x-tad-bigger>phone +</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>612 9929 9229</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>fax +</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>612 9460 4770</x-tad-bigger><x-tad-bigger> 
</x-tad-bigger>
<x-tad-bigger>web -</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>email -</x-tad-bigger><x-tad-bigger> </x-tad-bigger><x-tad-bigger>[EMAIL PROTECTED]
</x-tad-bigger>

Reply via email to