|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Blank Excel report
I am creating some reports that i want to have opened in Excel. I have put all data for the report in a table and have tried using cfcontent to have excel open the report. however, whenever excel opens it, it is always blank. if i display the report in goold ole HTML, i see that data just fine. Anybody got any ideas?
|
|
#2
|
|||
|
|||
|
Post the code please.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
||||
|
||||
|
<CFCONTENT TYPE="application/vnd.ms-excel">
<cfif #form.selectMetric# eq 2> <cfquery name="Metric2" datasource="#variables.datasource#"> SQL HERE </cfquery> <table border="1"> <tr><td><h2>Average number of redeliveries for the same Test Defect per project/release</h2></td></tr> <cfoutput query="Metric2"> <tr> <td>Release:</td><td>#form.ReleaseList#</td><td>Percent:</td><td>#decimalformat(metric2.count)#%</td> </tr> </cfoutput> </table> </cfif> |
|
#4
|
|||
|
|||
|
I'm doing it like this and it works fine:
<cfheader name="Content-disposition" value="inline; filename=exceldata.xls"> <cfcontent type="application/msexcel" reset="No"> ...html table for excel to render... |
|
#5
|
||||
|
||||
|
Well i found it seems to be something with my desktop (if i try using a different computer it comes up just fine).
|
|
#6
|
|||
|
|||
|
Quote:
I am having the same problem, some users are getting blank screen and others are not. Does anyone know why this would happen? Is it a browser or browser setting issue? John |
|
#7
|
||||
|
||||
|
Well i have been wrestling with the problem and it seems to be something with Microsoft Office. I have tried the code on a couple of machines, and the ones with 97 work fine, while any with 2002 will just show a blank document.
|
|
#8
|
||||
|
||||
|
Ok, i found the problem. Here is what you need to do, for you cfcontent and whatnot, use the following:
<cfsetting enablecfoutputonly="Yes"> <cfcontent type="application/msexcel"> <cfheader name="Content-disposition" value="filename=Metrics.xls"> Now here is the fun bit, you need to have all of your table, tr, td, etc tags enclosed in a cfoutput tag. don't know why it has the problem, but it at least solves the problem while looking for a cleaner solution. |
|
#9
|
|||
|
|||
|
Download to Excel as a "click here" link
I'm trying to download to excel as an option after the cfquery results are displayed in a browser. The results I get is also a blank excel report. I've tried to add the options you suggested "cfsetting enable output"...."cfheader..." but these tags return results automatically in excel which I don't want. Please review this code and offer any suggestions. Thanks!
<cfquery name="getName" datasource="xxxx" > SELECT * FROM tblEmployees </cfquery> <cffile action="write" file="Employee.xls" output=" <cfcontent type='application/vnd.ms-excel' > <table border='1'> <tr> <td>Last Name</td> <td>First Name</td> <td>Phone Number</td> </tr> " addnewline="Yes"> <cfoutput> <cfloop query="getName"> <cffile action="append" file="c:\TEMP\Employee.xls" output=" <tr> <td># Last_Name #</td> <td># First_Name #</td> <td># Phone_Number #</td> </tr>" addnewline="Yes"> </cfloop> </cfoutput> <cffile action="append" file="c:\TEMP\Employee.xls" output="</table> " addnewline="Yes"> <div align="center"> <a href="Employee.xls" onClick="getName">View Report in Excel</a> </div> |
|
#10
|
|||
|
|||
|
If you want to link directly to the .xls file then there's nothing else you can do except instruct the user to associate .xls files with Excel so that their browser knows not to display it but to open it with Excel. To the browser all it sees is HTML tags so that's what it outputs. Without adding in <cfheader> and <cfcontent> (which would prevent you from linking directly to the .xls file) there's no other way to tell the browser you really want to open it in Excel.
|
|
#11
|
||||
|
||||
|
well, after your query has run, display it in HTML with an option to save to Excel (which would resumbit the query). then place in some if then logic to turn on the cfheader information needed to display in excel.
|
|
#12
|
|||
|
|||
|
Blank Excel Report
Quote:
I used the same method and i got it correct.But the problem is the grids in the excel worksheet is not visible.Do anybody knows how to do it.. The worksheet grid shud be displayed for my Clients application. Please help me out in this regard |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Blank Excel report |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|