Office HTML Word 标题 [英] Office HTML Word header

查看:22
本文介绍了Office HTML Word 标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成Word 文档",在第一页上将标题作为 HTML 代码.<代码><样式>标签包含:

@page 部分 {尺寸:8.5 英寸 11.0 英寸;边距:0.7in 0.9in 0.7in 0.9in;mso-header-margin: 0.0in;mso-footer-margin: 0.0in;mso-title-page: 是;mso-first-header: fh1;mso-paper-source: 0;}div.Section {页:部分;}

:

<div class="Section" style="font-family: Verdana, sans-serif;"><![如果支持字段]><div style="mso-element:header" id="fh1"><p class="MsoHeader">标题</p>

<![endif]>

它在标题和文档主体中显示标题"文本.资源 (http://techsynapse.blogspot.com/2007/03/generating-word-document-dynamically.html 和 http://www.pbdr.com/ostips/wordfoot.htm) 我发现如果不使用额外的头文件就无法避免这种影响,这对我来说不是一个选项.

还有我的问题:你知道解决这个问题的任何方法吗?如何隐藏主文档中标题的出现,但将其保留在页面顶部的位置?提前感谢您的任何建议.

解决方案

这对我有用:

<head><title></title><!--[if gte mso 9]><xml><w:WordDocument><w:View>打印</w:View><w:Zoom>90</w:Zoom></w:WordDocument></xml><![endif]--><风格>p.MsoFooter, li.MsoFooter, div.MsoFooter{边距:0in;边距底部:.0001pt;mso-分页:寡妇孤儿;制表位:中心 3.0 英寸,右 6.0 英寸;字体大小:12.0pt;}<风格><!--/* 样式定义 */@页面第1节{尺寸:8.5 英寸 11.0 英寸;边距:1.0in 1.0in 1.0in 1.0in;mso-header-margin:.5in;mso-footer-margin:.5in;mso-title-page:是;mso-header: h1;mso-页脚:f1;mso-first-header: fh1;mso-first-footer: ff1;mso-paper-source:0;}div.Section1{页:第一节;}表#hrdftrtbl{边距:0in 0in 0in 900in;宽度:1px;高度:1px;溢出:隐藏;}--></style></head><body lang=EN-US style='tab-interval:.5in'>

<p>内容</p><br/><table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'><tr><td><div style='mso-element:header' id=h1 ><p class=MsoHeader ><p>&nbsp;HEADER-TITLE</p></p>

</td><td><div style='mso-element:footer' id=f1><p>&nbsp;页脚-标题</p><p class=MsoFooter><span style=mso-tab-count:2'></span>页面<span style='mso-field-code: PAGE'><span style='mso-no-proof:yes'></span></span><span style='mso-field-code: NUMPAGES'></span></p>

<div style='mso-element:header' id=fh1><p class=MsoHeader><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-HEADER-TITLE<o:p></o:p>;</span></p>

<div style='mso-element:footer' id=ff1><p class=MsoFooter><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-FOOTER-TITLE<o:p></o:p>;</span></p>

</td></tr></body></html>

I am generating "Word document" with a header on the first page as HTML code. <style> tag contains:

@page Section {
    size:8.5in 11.0in;
    margin: 0.7in 0.9in 0.7in 0.9in;
    mso-header-margin: 0.0in;
    mso-footer-margin: 0.0in;
    mso-title-page: yes;
    mso-first-header: fh1;
    mso-paper-source: 0;
}
div.Section {
    page: Section;
}

and <body>:

<div class="Section" style="font-family: Verdana, sans-serif;">
    <![if supportFields]>
        <div style="mso-element:header" id="fh1">
            <p class="MsoHeader">
                header
            </p>
        </div>
    <![endif]>
</div>

It shows the "header" text both in header and in the document's main body. The resources (http://techsynapse.blogspot.com/2007/03/generating-word-document-dynamically.html and http://www.pbdr.com/ostips/wordfoot.htm) I have found say that there is no way of avoiding this effect without using an additional header file which is not an option for me.

And there goes my question: do you know any work-around for that problem? How can I hide the occurence of the header in main document but leave it in its place at the top of the page? Thanks in advance for any piece of advice.

解决方案

This worked for me:

<html
xmlns:o='urn:schemas-microsoft-com:office:office'
xmlns:w='urn:schemas-microsoft-com:office:word'
xmlns='http://www.w3.org/TR/REC-html40'>
<head><title></title>

<!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Print</w:View>
  <w:Zoom>90</w:Zoom>
</w:WordDocument>
</xml><![endif]-->


<style>
p.MsoFooter, li.MsoFooter, div.MsoFooter
{
    margin:0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    tab-stops:center 3.0in right 6.0in;
    font-size:12.0pt;
}
<style>

<!-- /* Style Definitions */

@page Section1
{
    size:8.5in 11.0in;
    margin:1.0in 1.0in 1.0in 1.0in;
    mso-header-margin:.5in;
    mso-footer-margin:.5in;
    mso-title-page:yes;
    mso-header: h1;
    mso-footer: f1;
    mso-first-header: fh1;
    mso-first-footer: ff1;
    mso-paper-source:0;
}


div.Section1
{
    page:Section1;
}

table#hrdftrtbl
{
    margin:0in 0in 0in 900in;
    width:1px;
    height:1px;
    overflow:hidden;
}
-->
</style></head>

<body lang=EN-US style='tab-interval:.5in'>
<div class=Section1>

<p> CONTENT </p>

<br/>
    <table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'>
    <tr><td>

    <div style='mso-element:header' id=h1 >
        <p class=MsoHeader ><p>&nbsp;HEADER-TITLE</p></p>
    </div>

    </td>
    <td>
    <div style='mso-element:footer' id=f1>

        <p>&nbsp;FOOTER-TITLE</p>
        <p class=MsoFooter>
        <span style=mso-tab-count:2'></span>
            Page <span style='mso-field-code: PAGE '><span style='mso-no-proof:yes'></span></span> of <span style='mso-field-code: NUMPAGES '></span>
        </p>

    </div>



    <div style='mso-element:header' id=fh1>

    <p class=MsoHeader><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-HEADER-TITLE<o:p></o:p></span></p>

    </div>

    <div style='mso-element:footer' id=ff1>

    <p class=MsoFooter><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-FOOTER-TITLE<o:p></o:p></span></p>

    </div>

    </td></tr>
    </table>


</body></html>

这篇关于Office HTML Word 标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
前端开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆