cfhttp: how to use columns attribute when read a csv file in coldfusion



cfhttp: how to use columns attribute when read a csv file in coldfusion

employee1.csv

1, Jenny, Jones
2, Anne, Joli
3, Sonia, Fara
   


cfhttpColumns.cfm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>cfhttp: how to use columns attribute when read a csv file in coldfusion</title>
</head>

<body>
<h2 style="color:IndianRed; font-style:italic">cfhttp tag example: how to use columns attribute</h2>
<hr width="500" align="left" color="IndianRed" />
<br />

<cfhttp 
  method="get"
    url="http://localhost:8500/cfexample/employee1.csv" 
    name="EmployeeData"
    columns="EmpID,FirstName,LastName"
    firstRowAsHeaders="no"
    >
</cfhttp>

<table border="1" cellpadding="5" cellspacing="0" bordercolor="IndianRed">
    <tr bgcolor="Crimson" style="color:White; font-weight:bold">
        <td>
            Employee ID
        </td>
        <td>
            First Name
        </td>
        <td>
            Last Name
        </td>
    </tr>
 <cfoutput query="EmployeeData">
     <tr bgcolor="Snow" style="color:IndianRed; font-weight:normal">
         <td>
                #EmpID#
            </td>
         <td>
                #FirstName#
            </td>
         <td>
                #LastName#
            </td>
        </tr>
    </cfoutput>
</table>

</body>
</html>