Skip to main content
Known Participant
April 17, 2007
Answered

help value(s) of the excel csv is the same name as the heading

  • April 17, 2007
  • 1 reply
  • 424 views
There is no error.

Just the value(s) of the excel csv is the same name as the heading.

it is not the value of the field.
instead it is the name of <TH

Any tips?
This topic has been closed for replies.
Correct answer
Can you paste in your code so we can have a look?

Or read this article: http://www.universalwebservices.net/web-programming-resources/coldfusion/exporting-data-to-excel-coldfusion/

1 reply

Correct answer
April 18, 2007
Can you paste in your code so we can have a look?

Or read this article: http://www.universalwebservices.net/web-programming-resources/coldfusion/exporting-data-to-excel-coldfusion/
Known Participant
April 22, 2007
Thanks
here is the code.

<!--------------------
here is the first page where the user selects
html
pdf
escel/csv----------then it goes to a action page act_lop.cfm ---------------

<h1>LOP Reports </h1>
<div align="center">
<form name="theForm" action="act_lop.cfm" method="post"><BR />
Sorted by:  
<select name="Orderby" size="1">
<option value="CEEnum">CEE num</option>
<option value="Plot">plot No</option>
</select>
<br />
<br />
Output Format:
<input type="radio" name="outputFormat" value="HTML" checked="checked" />
HTML  
<input type="radio" name="outputFormat" value="PDF" />
PDF  
<input type="radio" name="outputFormat" value="CSV" />
Download/Open Excel Spreadsheet <BR />
<br />
<input name="Submit" type="Submit" value="Generate Report" />
<BR />
<BR />
<BR />
</form>
</div>

</body>
</html>



<!--------- act_lop.cfm the action page. Html and pdf is working ok but the problem is the excel sheet. --------------

<cfquery name="getlop" datasource="oracdb10">
select
tabTee.CEEnum,
tabTee.Plot,
FROM
tabTee

ORDER BY

<cfswitch expression="#Form.orderBy#">
<cfcase value="CEEnum">
tabTee.CEEnum
</cfcase>
<cfcase value="Plot">
tabTee.Plot
</cfcase>
</cfswitch>


</cfquery>


<!---html report--->
<cfswitch expression="#Form.outputFormat#">
<cfcase value="HTML,PDF">

<cfsavecontent variable="htmlData">
<!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=iso-8859-1" />
<title>lop</title>
</head>
<style type="text/css">

td{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
th{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
background-color:#FFFF99;
}
h2{
font-family:Arial, Helvetica, sans-serif;
font-size:14px;
}
h3{
font-family:Arial, Helvetica, sans-serif;
font-size:15px;
}
</style>

<body>
<cfoutput>
<table border="0" cellpadding="3" cellspacing="0">
<tr>

<td align="center">
<h3>lop</h3><br><br></td>
</tr>
<tr>
<td align="center">
</h2>Your report returned #getlop.RecordCount# records</h2></td>
</tr>
<tr>
<td>
<table border="2" cellpadding="2" cellspacing="0">
<tr>
<th>Record Number</th>

<th width="120">CEE num</th>
<TH>plot No</TH>

</tr>

<cfloop query="getlop">


<tr bgcolor="<cfif currentrow mod 2>GHOSTWHITE<cfelse>WHITE</cfif>">
<td>#CurrentRow#</td>

<Td>#CEEnum#</td>

<td>#Plot#</td>





</tr>
</cfloop>

</table>
</td>
</tr>
</table>

</BODY>
</HTML>
</cfoutput>
</cfsavecontent>

<cfswitch expression="#Form.outputFormat#">

<cfcase value="HTML">
<cfoutput>
#htmldata#
</cfoutput>
</cfcase>
<cfcase value="PDF">
PDF
<cfdocument format="pdf">
<cfoutput>
#htmldata#
</cfoutput>
</cfdocument>
</cfcase>

</cfswitch>





</cfcase>

<cfcase value="CSV">


<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=lop.csv">
<cfcontent type="application/msexcel">"Cee Num","plot No"
<cfoutput query="getlop"> #ltrim(CeeNum)#, #PLOT#
</cfoutput>

<cfabort>
</cfcase>
</cfswitch>


<!-----------------------------------csv---------------------------->

here is the las page

<cfquery name="getlop" datasource="oracdb10">
select
tabTee.CEEnum,
tabTee.Plot,
FROM
tabTee


ORDER BY
tabTee.CEEnum

</cfquery>



<CFHEADER NAME="Content-Disposition" VALUE="attachment; filename=lop.csv">
<cfcontent type="application/msexcel">"CEE num","plot No"
<cfoutput query="getlop">#CEEnum#,#Plot#
</cfoutput>