【问题标题】:Excel column heads on row 2 of export from ColdFusion从 ColdFusion 导出的第 2 行的 Excel 列标题
【发布时间】:2012-09-04 16:52:34
【问题描述】:

我希望从 ColdFusion 导出到 Excel 的表格带有下面的标题,以在电子表格的第 2 行显示列标题,并在首次查看时打开过滤。

<cfheader name="Content-Type" value="application/msexcel">
<html xmlns:x="urn:schemas-microsoft-com:office:excel">

如何设置样式和 XML 规范以获得此结果?

【问题讨论】:

    标签: excel coldfusion export styling


    【解决方案1】:

    最简单的方法是在 Excel 中创建一个具有您想要的功能的简单电子表格。然后将其保存为 HTML 并查看源代码,看看是如何使用的。

    这是我通过这样做创建的一个基本示例。控制过滤的主要属性是autofilterautofilterrange

    <!--- sample data --->
    <cfset someQuery = queryNew("")>
    <cfset queryAddColumn(someQuery, "ID", listToArray("10,22,14,51,62"))>
    <cfset queryAddColumn(someQuery, "Title", listToArray("AAA,BBB,CCC,DDD,EEE"))>
    
    <!--- generate --->
    <cfheader name="Content-Type" value="application/msexcel">
    <html xmlns:x="urn:schemas-microsoft-com:office:excel">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    </head>
    <body>
    <table>
    <!--- adjust filter range according to number of columns in query ---> 
    <tr><td x:autofilter="all" x:autofilterrange="$A$1:$B$1">ID</td>
        <td x:autofilter="all">Title</td>
    </tr>
    <cfoutput query="someQuery">
        <tr><td>#ID#</td>
            <td>#Title#</td>
        </tr>
    </cfoutput>
    </table>
    </body>
    </html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多