rudodoo
asked on
Excel export isn't formatting correctly in Coldfusion MX 7
I'm trying to export a report in Excel using Coldfusion, however all the data displays in just 1 cell. How do I make the report display the way it want it to.
Here is my code for the excel report
<cfswitch expression="#form.report#" >
<cfcase value="1">
<!--- feature --->
<cfinclude template="qry_feature.cfm" >
<cfset strReport = 'Feature Report'>
</cfcase>
<cfcase value="2">
<!--- feature same day add/delete --->
<cfinclude template="qry_featuresamed ayadddelet e.cfm">
<cfset strReport = 'Features Same Day ADD/DEL Report'>
</cfcase>
<cfcase value="3">
<!--- feature same day add/delete --->
<cfinclude template="qry_servicesamed ayadddelet e.cfm">
<cfset strReport = 'Services Same Day ADD/DEL Report'>
</cfcase>
<cfcase value="4">
<!--- feature same day add/delete --->
<cfinclude template="qry_servicedupes .cfm">
<cfset strReport = 'Service Duplicates Report'>
</cfcase>
<cfcase value="5">
<!--- feature same day add/delete --->
<cfinclude template="qry_prepaydupe.c fm">
<cfset strReport = 'Prepay Duplicates Report'>
</cfcase>
<cfcase value="6">
<!--- feature same day add/delete --->
<cfinclude template="qry_contractdupe s.cfm">
<cfset strReport = 'Contract Duplicates Report'>
</cfcase>
<cfcase value="7">
<!--- feature same day add/delete --->
<cfinclude template="qry_featuredupe. cfm">
<cfset strReport = 'Feature Duplicate Report'>
</cfcase>
<cfdefaultcase>
<p>error!</p>
</cfdefaultcase>
</cfswitch>
<cfset strReport = strReport & ' Current Cycledates: ' & form.cycledates &' '>
<cfset strReport = strReport & 'Current Markets: '>
<cfif form.which_markets NEQ ''>
<cfset strReport = strReport & form.which_markets & ' '>
<cfelse>
<cfset strReport = strReport & 'All Markets '>
</cfif>
<cfset strReport = strReport & 'Current Channels: '>
<cfif form.which_channels NEQ ''>
<cfset strReport = strReport & form.which_channels & ' '>
<cfelse>
<cfset strReport = strReport & 'All Channels '>
</cfif>
<cfsavecontent variable="outitgoes"><cfou tput>#strR eport##chr (13)#</cfo utput>
<cfoutput>#Replace('#getma in.columnl ist#',',', chr(0009), 'ALL')##chr(13)#</cfoutput >
<cfoutput query="getmain">
<cfloop index="i" list="#getmain.columnlist# ">
#evaluate(i)##chr(0009)#
</cfloop>
</cfoutput>
</cfsavecontent>
<CFHEADER NAME="Content-Disposition" VALUE="Inline;filename=fil tereddata# CreateUUID ()#.xls">
<cfcontent type="application/vnd.ms-e xcel" >
<cfoutput>#outitgoes#</cfo utput>
I want it similiar to whats displayed on the screen when a user runs the report. Here is an example of that code
<table class="reportTable">
<tr>
<th class="reportHeader">Marke t</th>
<th class="reportHeader">Chann el</th>
<th class="reportHeader">Empli d</th>
<th class="reportHeader">Accou ntnbr</th>
<th class="reportHeader">Phone nbr</th>
<th class="reportHeader">Ratep lan</th>
<th class="reportHeader">Recor dtype</th>
<th class="reportHeader">Servi cetype</th >
<th class="reportHeader">Produ ct</th>
<th class="reportHeader">Count (inputseq) </th>
</tr>
<cfoutput query="getmain" >
<tr>
<td class="reportCell">#getmai n.Market#< /td>
<td class="reportCell">#getmai n.Channel# </td>
<td class="reportCell">#getmai n.Emplid#< /td>
<td class="reportCell">#getmai n.Accountn br#</td>
<td class="reportCell">#getmai n.Phonenbr #</td>
<td class="reportCell">#getmai n.rateplan #</td>
<td class="reportCell">#getmai n.Recordty pe#</td>
<td class="reportCell">#getmai n.Servicet ype#</td>
<td class="reportCell">#getmai n.Product# </td>
<td class="reportCell">#getmai n.Countinp utseq#</td >
</tr>
</cfoutput>
</table>
Here is my code for the excel report
<cfswitch expression="#form.report#"
<cfcase value="1">
<!--- feature --->
<cfinclude template="qry_feature.cfm"
<cfset strReport = 'Feature Report'>
</cfcase>
<cfcase value="2">
<!--- feature same day add/delete --->
<cfinclude template="qry_featuresamed
<cfset strReport = 'Features Same Day ADD/DEL Report'>
</cfcase>
<cfcase value="3">
<!--- feature same day add/delete --->
<cfinclude template="qry_servicesamed
<cfset strReport = 'Services Same Day ADD/DEL Report'>
</cfcase>
<cfcase value="4">
<!--- feature same day add/delete --->
<cfinclude template="qry_servicedupes
<cfset strReport = 'Service Duplicates Report'>
</cfcase>
<cfcase value="5">
<!--- feature same day add/delete --->
<cfinclude template="qry_prepaydupe.c
<cfset strReport = 'Prepay Duplicates Report'>
</cfcase>
<cfcase value="6">
<!--- feature same day add/delete --->
<cfinclude template="qry_contractdupe
<cfset strReport = 'Contract Duplicates Report'>
</cfcase>
<cfcase value="7">
<!--- feature same day add/delete --->
<cfinclude template="qry_featuredupe.
<cfset strReport = 'Feature Duplicate Report'>
</cfcase>
<cfdefaultcase>
<p>error!</p>
</cfdefaultcase>
</cfswitch>
<cfset strReport = strReport & ' Current Cycledates: ' & form.cycledates &' '>
<cfset strReport = strReport & 'Current Markets: '>
<cfif form.which_markets NEQ ''>
<cfset strReport = strReport & form.which_markets & ' '>
<cfelse>
<cfset strReport = strReport & 'All Markets '>
</cfif>
<cfset strReport = strReport & 'Current Channels: '>
<cfif form.which_channels NEQ ''>
<cfset strReport = strReport & form.which_channels & ' '>
<cfelse>
<cfset strReport = strReport & 'All Channels '>
</cfif>
<cfsavecontent variable="outitgoes"><cfou
<cfoutput>#Replace('#getma
<cfoutput query="getmain">
<cfloop index="i" list="#getmain.columnlist#
#evaluate(i)##chr(0009)#
</cfloop>
</cfoutput>
</cfsavecontent>
<CFHEADER NAME="Content-Disposition"
<cfcontent type="application/vnd.ms-e
<cfoutput>#outitgoes#</cfo
I want it similiar to whats displayed on the screen when a user runs the report. Here is an example of that code
<table class="reportTable">
<tr>
<th class="reportHeader">Marke
<th class="reportHeader">Chann
<th class="reportHeader">Empli
<th class="reportHeader">Accou
<th class="reportHeader">Phone
<th class="reportHeader">Ratep
<th class="reportHeader">Recor
<th class="reportHeader">Servi
<th class="reportHeader">Produ
<th class="reportHeader">Count
</tr>
<cfoutput query="getmain" >
<tr>
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
<td class="reportCell">#getmai
</tr>
</cfoutput>
</table>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Also, the problem is still happening on one of the reports titled Feature Report
Unfortunately I couldn't reproduce your problems. I tried a query with 0 results and all my columns still return in their own cells. If the code works the majority of the time, then all I can suggest is trial and error of pinpointing exactly what data in the database is making the results go haywire.
Also, take a look inside your cfincludes. You may have code in there that is causing the disruption.
Also, take a look inside your cfincludes. You may have code in there that is causing the disruption.
ASKER