我有一个包含动态内容的HTML页面,使用Word打开并使用以下布局:
我找到了一个使用Office XML和CSS添加页眉和页脚的模板。我在页脚中添加了徽标和页码。我一直在寻找一种方法让页脚显示从第2页开始(包括徽标和页码)。在MS Word 2007中,选择页眉/页脚时有一个选项; 设计标签 - > 选项菜单 - > 不同的第一页在第一页中不显示页眉和页脚。
我一直在尝试使用包含Cover页面的div类来显示CSS:display属性:
.coverP #Section1
{ display:none;}
没有成功。我已经修剪了我的网页内容以作为示例以及下面的代码(来源a link!)
如果有人知道如何做到这一点,我们将不胜感激。
<%@ Language="VBScript" %>
<%
'test
%>
<apex:page sidebar="false" contentType="application/msword" cache="true">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<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'>
<html xmlns:w="urn:schemas-microsoft-com:office:word">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns='http://www.w3.org/TR/REC-html40'
xmlns:w="urn:schemas-microsoft-com:office:word">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<title>Report</title>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape{behavior:url(#default#VML);}
</style>
<style>
p.MsoHeader, li.MsoHeader, div.MsoHeader{
margin:0in;
margin-top:.0001pt;
mso-pagination:widow-orphan;
tab-stops:center 3.0in right 6.0in;
}
p.MsoFooter, li.MsoFooter, div.MsoFooter{
margin:0in;
margin-bottom:.0001pt;
mso-pagination:widow-orphan;
tab-stops:center 3.0in right 6.0in;
}
@page Section1{
size:8.5in 11.0in;
margin:0.5in 0.5in 0.5in 0.5in;
mso-header-margin:0.5in;
mso-header:h1;
mso-footer:f1;
mso-footer-margin:0.5in;
mso-paper-source:0;
}
div.Section1{
page:Section1;
}
table#hrdftrtbl{
margin:0in 0in 0in 9in;
}
</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>
<p>Page 3 data part of report goes here </p>
</div>
<!-- End of page 3 -->
<!--Header and Footer Starts-->
<table id='hrdftrtbl' border='1' cellspacing='0' cellpadding='0'>
<tr>
<td>
<!--Header-->
<div style='mso-element:header' id="h1" >
<p class="MsoHeader">
</p>
</div>
</td>
<td>
<!--Footer-->
<div style='mso-element:footer' id="f1">
<p class="MsoFooter">
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="30%">
</td>
<td align="center" width="40%">
<!-- Footer Logo-->
<div align="center"><img src="logo.png"> </div>
</td>
<td align="right" width="30%">
Page <span style='mso-field-code: PAGE '></span>
</td>
</tr>
</table>
</p>
</div>
</td>
</tr>
</table>
</div>
</body>
</html>
</apex:page>
<%
Response.Buffer = true
Response.ContentType = "application/vnd.ms-word"
Response.AddHeader "content-disposition","inline;filename=report.doc"
%>
答案 0 :(得分:1)
我遇到了同样的问题,终于找到了答案。您必须设置以下内容:
mso-title-page: yes;
然后当您附加页眉和页脚时,请mso-
替换mso-first-
:
mso-first-header:h1;
mso-first-footer:f1;
它的测试和工作