Hey People I got this code from Stack Exchange only But It's Not what I'm looking for, I feel here header and Footer are static, Please somebody guide me to make running header and footer when i render page as MS Word
<apex:page sidebar="false"
showChat="false"
showHeader="false"
contentType="application/msword#Test.doc"
cache="true">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style>
@page Main {
mso-header:h1;
mso-footer:f1;
}
div.Main{
page:Main;
}
p.MyFoot, li.MyFoot, div.MyFoot{
mso-pagination:widow-orphan;
tab-stops:center 216.0pt right 432.0pt;
}
p.MyHead {
}
</style>
</head>
<div class="Main">
<div style="mso-element:header" id="h1">
<p class="MyHead">Header Text</p>
</div>
<div style="mso-element:footer" id="f1">
<p class="MyFoot">
<span style='mso-field-code:" FILENAME "'> </span>
<span style='mso-tab-count:2'></span>
Page <span style='mso-field-code:" PAGE "'></span> of <span style='mso-field-code:" NUMPAGES "'></span>
</p>
</div>
</div>
</apex:page>
Best Answer
I think the issue you are having is that the 'template' for the header and footer gets displayed in the main content. Otherwise the header and footer do display correctly - at least they did for me. I found the solution to remove the 'template' in another post. Check it out here