Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active February 8, 2016 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamoCA/75399b2eee3ad792a2e7 to your computer and use it in GitHub Desktop.
Save JamoCA/75399b2eee3ad792a2e7 to your computer and use it in GitHub Desktop.
Convert CSV file to Excel XLSX using ColdFusion & CFExecute
<CFSAVECONTENT VARIABLE="CSVData">"Header1","Header2"
1,"Name 1"
2,"Name 2"
</CFSAVECONTENT>
<CFSET InFile = "#Request.workdir#\CSV_#Request.DateHash(14,Request.Now)#.csv">
<CFSET OutFile = "#Request.workdir#\Excel_#Request.DateHash(14,Request.Now)#.xlsx">
<cffile action="WRITE" file="#InFile#" output="#CSVData#" addnewline="No" fixnewline="No">
<cfexecute name="C:\TotalCSVConverter\CSVConverter.exe" arguments="""#InFile#"" ""#OutFile#"" -kfs -c XLSX -comma ##44 -quote ##34 -fh -TM 0.5 -LM 0.5 -BM 0.5 -RM 0.5 -ps A4" variable="Response" timeout="60"></cfexecute>
<cffile action="DELETE" file="#InFile#">
<cfheader name="content-disposition" value="attachment; filename=Download.xlsx">
<cfcontent type="application/unknown" file="#OutFile#" deletefile="Yes">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment