如何在导出的word文档中添加页眉和页脚 [英] how to add header and footer in exported word document
本文介绍了如何在导出的word文档中添加页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在导出的word文档中添加页眉和页脚?
how to add header and footer in exported word document?
StringBuilder strHTMLContent = new StringBuilder();
strHTMLContent.Append(@"<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>Time</title>");
strHTMLContent.Append(@"<xml>" +
"<w:worddocument xmlns:w="#unknown">" +
"<w:view>Print</w:view>" +
"<w:zoom>90</w:zoom>" +
"</w:worddocument>" +
"</xml>");
string strFileName = "xxx"+".doc";
strHTMLContent.Append("<style>" +
"p.MsoHeader, li.MsoHeader, div.MsoHeader " +
"{margin:0in;" +
"margin-bottom:.0001pt; " +
"mso-pagination:widow-orphan; " +
"tab-stops:center 3.0in right 6.0in; " +
"font-size:10.0pt; " +
"font-family:'Times New Roman';}");
strHTMLContent.Append(@"page Section1" +
" {size:8.5in 11.0in; " +
" margin:1.0in 1.25in 1.0in 1.25in ; " +
" mso-header-margin:.5in; " +
" mso-header: h1; " +
" mso-footer: f1;" +
" mso-footer-margin:.5in; mso-paper-source:0;}" +
" div.Section1" +
" {page:Section1;}" +
"</style></head>");
Response.AddHeader("Content-Type", "application/msword");
Response.AppendHeader("Content-disposition", "attachment; filename=" + strFileName);
HttpContext.Current.Response.Write(strHTMLContent);
Response.Write(strHTMLContent);
推荐答案
访问
http://msdn.microsoft.com/en-us/library /ms178795(v=vs.80).aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/vstudio/ms178795.aspx [ ^ ]
希望这会有所帮助
visit
http://msdn.microsoft.com/en-us/library/ms178795(v=vs.80).aspx[^]
http://msdn.microsoft.com/en-us/library/vstudio/ms178795.aspx[^]
hope this will help
这篇关于如何在导出的word文档中添加页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文