Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying a page as an Excel Spreadsheet in IE

Status
Not open for further replies.

JohnBeals

Programmer
Feb 26, 2002
49
US
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=&quot;TestData&quot; datasource=&quot;Test&quot;>
Select * from table
where this = that
</cfquery>


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
<title>Excel Display Test</title>
</head>

<body>
<cfcontent type=&quot;application/vnd.ms-excel&quot;>
<cfdump var=#TestData#>

</body>
</html>


Second Try

<body>
<cfcontent type=&quot;application/vnd.ms-excel&quot;>
<!--- <cfdump var=#TestData#> --->
<table cellspacing=&quot;2&quot; cellpadding=&quot;2&quot; border=&quot;0&quot;>
<cfoutput query=&quot;TestData&quot;>
<tr>
<td>#JobNumber#</td>
<td>#ProductCode#</td>
</tr>
</cfoutput>
</table>

</body>
 
Try adding a header:

<cfheader name=&quot;content-disposition&quot; value=&quot;inline; filename=filename.xls&quot;>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top