Last active
February 8, 2016 17:53
-
-
Save JamoCA/75399b2eee3ad792a2e7 to your computer and use it in GitHub Desktop.
Convert CSV file to Excel XLSX using ColdFusion & CFExecute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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