Link to home
Start Free TrialLog in
Avatar of rudodoo
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_featuresamedayadddelete.cfm">
            <cfset strReport = 'Features Same Day ADD/DEL Report'>
      </cfcase>
      
      <cfcase value="3">
      <!--- feature same day add/delete --->
            <cfinclude template="qry_servicesamedayadddelete.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.cfm">
            <cfset strReport = 'Prepay Duplicates Report'>
      </cfcase>

<cfcase value="6">
      <!--- feature same day add/delete --->
            <cfinclude template="qry_contractdupes.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"><cfoutput>#strReport##chr(13)#</cfoutput>
      <cfoutput>#Replace('#getmain.columnlist#',',',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=filtereddata#CreateUUID()#.xls">
<cfcontent type="application/vnd.ms-excel" >
<cfoutput>#outitgoes#</cfoutput>

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">Market</th>
            <th class="reportHeader">Channel</th>
            <th class="reportHeader">Emplid</th>
            <th class="reportHeader">Accountnbr</th>
            <th class="reportHeader">Phonenbr</th>
            <th class="reportHeader">Rateplan</th>
            <th class="reportHeader">Recordtype</th>
            <th class="reportHeader">Servicetype</th>
            <th class="reportHeader">Product</th>
            <th class="reportHeader">Count(inputseq)</th>
      </tr>
      <cfoutput query="getmain" >
            <tr>
                  <td class="reportCell">#getmain.Market#</td>
                  <td class="reportCell">#getmain.Channel#</td>
                  <td class="reportCell">#getmain.Emplid#</td>
                  <td class="reportCell">#getmain.Accountnbr#</td>
                  <td class="reportCell">#getmain.Phonenbr#</td>
                  <td class="reportCell">#getmain.rateplan#</td>
                  <td class="reportCell">#getmain.Recordtype#</td>
                  <td class="reportCell">#getmain.Servicetype#</td>
                  <td class="reportCell">#getmain.Product#</td>
                  <td class="reportCell">#getmain.Countinputseq#</td>
            </tr>
      </cfoutput>
</table>
ASKER CERTIFIED SOLUTION
Avatar of js_vaughan
js_vaughan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rudodoo
rudodoo

ASKER

When I run a report that doens't have any data included it still shows all the column headers in one cell.  Is there a way fix that
Avatar of rudodoo

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.