9

次のコードを使用して Word 形式の .doc を作成し、次に cfheader と cfcontent を作成しています。すべて問題ありませんが、ヘッダー (またはフッター) に動的な情報を配置できるようにする必要があります。そうしないと、自動ページ番号付けが次善の策になります。

コードをどのように変更すればよいですか?

<cfsavecontent variable="myDocument">
<html xmlns:w="urn:schemas-microsoft-com:office:word">
<!--- Head tag instructs Word to start up a certain way, specifically in
print view. --->
    <head>
        <xml>
         <w:WordDocument>
            <w:View>Print</w:View>
            <w:SpellingState>Clean</w:SpellingState>
            <w:GrammarState>Clean</w:GrammarState>
            <w:Compatibility>
             <w:BreakWrappedTables/>
             <w:SnapToGridInCell/>
             <w:WrapTextWithPunct/>
             <w:UseAsianBreakRules/>
            </w:Compatibility>
            <w:DoNotOptimizeForBrowser/>
         </w:WordDocument>
        </xml>
    </head>
<body>
    Regular HTML document goes here
    <!--- Create a page break microsoft style (took hours to find this) 
--->
    <br clear="all"
style="page-break-before:always;mso-break-type:page-break" />
    Next page goes here
</body>
</html>
</cfsavecontent> 
4

2 に答える 2

4

これを見てください:ヘッダー とフッター この記事を使用して、たった 1 つの html ファイルでカスタム ヘッダーとフッターを作成することに成功しました。(ワード 2003)

お役に立てれば!

于 2010-08-17T14:40:28.840 に答える
1

WordprocessingML を使用してページ番号を追加するのは簡単ではないようです

http://openxmldeveloper.org/archive/2006/08/03/443.aspx

DOC の代わりに PDF を提供できる場合は、ページ番号付けのソリューションを次に示します。

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c21.html

例 2 を参照してください。

<cfdocument format="pdf"> 
<cfdocumentitem type="header" evalatprint="true"> 
    <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
        <tr><td align="right"><cfoutput>#cfdocument.currentsectionpagenumber# of 
            #cfdocument.totalsectionpagecount#</cfoutput></td></tr> 
    </table> 
</cfdocumentitem> 

<cfdocumentitem type="footer" evalatprint="true"> 
    <table width="100%" border="0" cellpadding="0" cellspacing="0"> 
        <tr><td align="center"><cfoutput>#cfdocument.currentpagenumber# of 
            #cfdocument.totalpagecount#</cfoutput></td></tr> 
    </table> 
</cfdocumentitem> 

...    

</cfdocument>
于 2010-08-11T19:27:56.487 に答える