从ColdFusion导出到Excel,如何修改页面设置?

我从ColdFusion 9导出到Excel,我想设置页面的方向和缩放,以便导出的Excel文档适合页面和打印景观。 如何做到这一点?

编辑解决scheme:
感谢您的帮助。 页面方向设置按照广告方式工作。
我用下面的黑客来适应页面宽度。

此页面包含有关可能的各种设置的文档:
http://msdn.microsoft.com/en-us/library/Aa155477%28office.10%29.aspx

<cfheader name="Content-disposition" value="attachment;filename=export.xls"> <cfcontent type="application/application/vnd.ms-excel"> <!--- mso-page-orientation:landscape causes the exported excel spreadsheet to be printed landscape. Setting Scale=45 causes the printout to fit to page width for me. Per the documentation, I should be able to set <x:Print><x:FitWidth>1</x:FitWidth><x:FitHeight>32767</x:FitHeight><x:ValidPrinterInfo/></x:Print> but it doesn't want to work. The width and height appear correctly in the Page Setup dialog, but the 'Adjust to' scale size radio button remains selected instead of the 'Fit to' one page wide by 32767 tall radio button. ---> <HTML xmlns:x="urn:schemas-microsoft-com:office:excel"> <HEAD> <STYLE> <!--table @page {mso-page-orientation:landscape;} --> </STYLE> <!--[if gte mso 9]><xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:WorksheetOptions> <x:Print> <x:ValidPrinterInfo/> <x:Scale>45</x:Scale> </x:Print> </x:WorksheetOptions> </x:ExcelWorksheet> </x:ExcelWorksheets> </x:ExcelWorkbook> </xml><![endif]--> </HEAD> <BODY> <cfoutput> <cfloop from = "1" to = "#arrayLen(reportItems)#" index = "i"> <table cellpadding="1" cellspacing="1" bgcolor="dcdcdc" width="100%" border="1"> ... table contents ... </table> </cfloop> </cfoutput> </BODY> </HTML> 

你可以使用这个页面logging的一个技巧:

如何在传输MIME内容的同时格式化Excel工作簿

基本上,你输出一个标准的HTML数据表,你想打开一个Excel电子表格。 您还必须为Excel指定mimetypes,为了更好的衡量,我还想指定content-disposition标题以提示更好的下载文件名称。

 <cfcontent type="application/msexcel"/> <cfheader name="content-disposition" value="attachment; filename=myFile.xls"> 

那么你的具体格式问题的关键也在上面的链接中find。 你需要在MS Office特定的CSS规则mso-page-orientation:landscape;包含一个<style>mso-page-orientation:landscape; 。 从那个链接:

 <style> <!--table @page {mso-header-data:"&CMultiplication Table\000ADate\: &D\000APage &P"; mso-page-orientation:landscape;} br {mso-data-placement:same-cell;} --> </style> 

这应该处理页面方向问题。 有一点需要注意 – Office 2007和更新版本会在打开此文件时向用户发出不同内容types的警告。 这只是一个烦恼(可以通过registry更新来禁用); 一切仍然会按需要工作和运作。

IIRC没有什么可以烘烤的。但是你可以挖掘底层的工作簿并使用一点POI魔法。 (请注意,这些打印设置应用于每张纸上)

 <!--- get the underlying poi sheet ---> <cfset poiSheet = cfSheetObject.getWorkBook().getSheet("TheSheetName")> <cfset ps = poiSheet.getPrintSetup()> <cfset ps.setLandscape(true)> <!--- fit to one page ---> <cfset ps.setFitHeight(1)> <cfset ps.setFitWidth(1)> 

在cfspreadsheet标签中没有看到任何属性可以实现这一点。 来自土坯网站:

  <cfspreadsheet action="write" filename = "filepath" format = "csv" name = "text" overwrite = "true | false" password = "password" query = "queryname" sheetname = "text" > 

在使用打印范围或类似的东西在Excel中导出之后,您可能必须这样做。

让CFpipe理导出正确的数据,让Excel处理格式化/打印。