• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

html to excel with cfcontent problem

Guest
Apr 27, 2006 Apr 27, 2006

Copy link to clipboard

Copied

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>
TOPICS
Advanced techniques

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Apr 28, 2006 Apr 28, 2006
Well, I don't know XML, but when I replaced <x:Name>Change Packages</x:Name> with <x:Name>#filename#</x:Name>, using the variable instead of the static text string, it worked and the Bold and Landscape orientation worked.

Thanks,

Jeff

Votes

Translate

Translate
Community Expert ,
Apr 28, 2006 Apr 28, 2006

Copy link to clipboard

Copied

What happens when you begin with

<cfset filename = "Facets_Fix_Report_#fileDate#.xls">
<cfheader name="Content-Disposition" value="inline; filename=#trim(filename)#">
<cfcontent type="application/vnd.ms-excel">
<html xmlns: o="urn:schemas-microsoft-com: office: office"
xmlns:x="urn:schemas-microsoft-com: office:excel">
xmlns=" http://www.w3.org/TR/REC-html40">
<HEAD>
...
etc.



P.S.: To get rid of those emoticons, insert a space between x: and p.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 28, 2006 Apr 28, 2006

Copy link to clipboard

Copied

LATEST
Well, I don't know XML, but when I replaced <x:Name>Change Packages</x:Name> with <x:Name>#filename#</x:Name>, using the variable instead of the static text string, it worked and the Bold and Landscape orientation worked.

Thanks,

Jeff

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation