I am attempting to allow a user to save the contents of a
table created with a cfquery into an Excel spreadsheet. Using
<cfcontent> I am able to create the spreadsheet fine, but the
formatting is not right. Some of it is and some of it is not. The
bold on the header line doesn't happen, which I can live with, but
the landscape orientation does not and that is a bigger problem. I
view it fine in Excel 2003 but when I print preview or print it is
portrait. I have converted this code from ASP. It has the XML
inside, so I kept it..
We are still on CF5. Not sure if there's a way to resolve
this issue.
Thanks for any help on this.
Jeff
<cfsetting enablecfoutputonly="Yes">
<cfset filename = "Facets_Fix_Report_#fileDate#.xls">
<cfcontent type="application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="attachment;
filename=#trim(filename)#">
<cfoutput>
<HTML xmlns:x="urn:schemas-microsoft-com:office:excel">
<HEAD>
<style>
<!--
td
{
border-width: thin;
border-top-style:solid;
border-bottom-style:solid;
border-left-style:solid;
border-right-style:solid;
}
@page
{
mso-header-data:"&C&\0022Arial\,Bold\0022&12#trim(strHeader)#";
mso-footer-data:"&L \00A9 #DateFormat(Now(),'YYYY')#\,
The TriZetto Group &CPage &P of &N &RExported on\:
&D &T";
mso-page-orientation:landscape;
margin:1in .5in .6in .5in;
}
br
{
mso-data-placement:same-cell;
mso-width-source:auto;
}
newclass
{
mso-width-source:auto;
}
-->
</style>
<!-- [if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Change Packages</x:Name>
<x:WorksheetOptions>
<x:Print>
<x:ValidPrinterInfo/>
<x:VerticalResolution>600</x:VerticalResolution>
</x:Print>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveCol>5</x:ActiveCol>
<x:RangeSelection>$A$1:$F$2</x:RangeSelection>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>10005</x:WindowHeight>
<x:WindowWidth>10005</x:WindowWidth>
<x:WindowTopX>120</x:WindowTopX>
<x:WindowTopY>135</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
<x:ExcelName>
<x:Name>Print_Titles</x:Name>
<x:SheetIndex>1</x:SheetIndex>
<x:Formula>=Recovered_Sheet1!$1:$2</x:Formula>
</x:ExcelName>
</xml><![endif] -->
</HEAD>