Leading Zero in Zip Code Removed - CSV Export with Java StringBuffer
Hi Everyone,
I am in the middle of creating a CSV file export. I'm currently using the Java StringBuffer class to append my query data and then output the data using cfcontent. Anyway, I noticed that the Zip Code field has removed the first leading zero.
- How can I modify my code to allow for the entire zip code to be displayed. When I originally used cffile was able to wrap a variable in quotes and that preserved it. However, I am not using cffile since it has slowed the export considerably.
- Also one of the address fields contained a comma that caused a blank column to be added - shifting some of my content. I replaced the comma with a blank and that removed the comma but the added column still exists. Any idea on how to resolve that?
Here is a sample of the code
<cfscript>
csvExport = createObject("java", "java.lang.StringBuffer");
csvExport.append("First Name,Last Name,Address1,Address2,City,State,Zip Code,Local,Workshop" & Chr(13) & Chr(10));
</cfscript>
<cfoutput query="oExpRegistrants">
<cfscript>
Replace(reg_address2, ",","");
csvExport.append(firstname & ",");
csvExport.append(lastname & ",");
csvExport.append(reg_address1 & ",");
csvExport.append(reg_address2 & ",");
csvExport.append(reg_city & ",");
csvExport.append(reg_state & ",");
csvExport.append(reg_zip & ",");
csvExport.append(reg_local & ",");
csvExport.append(thisExpWorkshop);
csvExport.append(Chr(13) & Chr(10));
</cfscript>
</cfoutput>
Thanks in advance for your help.
