You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在通过HTML生成Word文档时实现仅从第二页开始显示页脚

实现页脚仅从第二页显示的修改方案

你需要做3处调整即可实现需求,不需要替换原有mso-header/mso-footer配置,仅需新增首页专属配置:

  1. 在@page Section1的样式规则中添加mso-title-page: yes;,该属性的作用是告诉Word当前节包含独立标题页(也就是你的第一页封面),标题页可使用单独的页眉页脚规则。
  2. 同样在@page Section1中新增两条首页页眉页脚的指向配置,指定首页使用空的页眉页脚:
    • mso-first-header: h0;
    • mso-first-footer: f0;
  3. 在页眉页脚定义区域新增两个内容为空的页眉页脚元素,对应上一步配置的h0和f0ID。

修改后的完整代码如下:

<head>
    <style type="text/css" media="print">
          @page Section1 {
              size:8.3in 11.7in;
              mso-footer:f1;
              mso-header:h1;
              /* 新增以下3行配置 */
              mso-title-page: yes;
              mso-first-header: h0;
              mso-first-footer: f0;
              margin:0.0in 0.6in 0.0in 0.6in;
              mso-header-margin:0.0in;
              mso-footer-margin:0.0in;
          }
        
          div.Section1{ 
            page:Section1;
          }
          
          p.MsoFooter, li.MsoFooter, div.MsoFooter { 
              mso-pagination:widow-orphan;
          }
    </style>
</head>
<body>
    <!-- Content -->
    <div class="Section1">
        <!-- Cover Page 1  -->
        <div class="coverP">
        Cover page text goes here
        </div>

        <br clear="all" style="page-break-before:always" />

        <!-- Page 2 Starts -->
       <div>
       Page 2 goes here with footer (pg#2 and logo)
       </div>

       <br clear="all" style="page-break-before:always" />
       <!-- Page 3 Starts -->
        <div>
           page 3 go here with footer (pg#2 and logo)
         </div>  
<!---------- HEADER AND FOOTER SECTIONS ---------------&gt;
      <!-- 新增空的首页页眉页脚 -->
      <div style="mso-element:header" id="h0">
      <!-- 无内容,首页不显示页眉 -->
      </div> 
      <div style="mso-element:footer" id="f0" >
      <!-- 无内容,首页不显示页脚 -->
      </div>

      <div style="mso-element:header" id="h1">
      <table>...</table> 
      </div> 

   <div style="mso-element:footer" id="f1" >
   <table>...</table>  
</div>
</div>
</body>
</html>

内容的提问来源于stack exchange,提问作者Thaís C.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 08:36:02