I need to display an Excel Spreadsheet in IE. CF creates a report, which I am currently displaying in a table. There is a similar report in .asp that displays the excel spreadsheet in IE, using Response.ContentType = "application/vnd.ms-excel" (at least I think that's what's causing the display in Excel
I wrote a small test file to try to get this working. I do a cfquery, then display it in a cfdump (temporarily). When I run the page I get "You have chosen to download a file from this location:
TestExcel.cfm from If I select "Open this file from its current location" I get the Excel Spreadsheet but no data.
Under the "Second Try" code listing, I just get the data in a table. No Excel.
What I want it to do is simply display the query results in Excel in IE.
What am I doing wrong?
<cfquery name="TestData" datasource="Test">
Select * from table
where this = that
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Excel Display Test</title>
</head>
<body>
<cfcontent type="application/vnd.ms-excel">
<cfdump var=#TestData#>
</body>
</html>
Second Try
<body>
<cfcontent type="application/vnd.ms-excel">
<!--- <cfdump var=#TestData#> --->
<table cellspacing="2" cellpadding="2" border="0">
<cfoutput query="TestData">
<tr>
<td>#JobNumber#</td>
<td>#ProductCode#</td>
</tr>
</cfoutput>
</table>
</body>
I wrote a small test file to try to get this working. I do a cfquery, then display it in a cfdump (temporarily). When I run the page I get "You have chosen to download a file from this location:
TestExcel.cfm from If I select "Open this file from its current location" I get the Excel Spreadsheet but no data.
Under the "Second Try" code listing, I just get the data in a table. No Excel.
What I want it to do is simply display the query results in Excel in IE.
What am I doing wrong?
<cfquery name="TestData" datasource="Test">
Select * from table
where this = that
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Excel Display Test</title>
</head>
<body>
<cfcontent type="application/vnd.ms-excel">
<cfdump var=#TestData#>
</body>
</html>
Second Try
<body>
<cfcontent type="application/vnd.ms-excel">
<!--- <cfdump var=#TestData#> --->
<table cellspacing="2" cellpadding="2" border="0">
<cfoutput query="TestData">
<tr>
<td>#JobNumber#</td>
<td>#ProductCode#</td>
</tr>
</cfoutput>
</table>
</body>