如何从asp.net删除在Word文档中生成的重复单词页眉/页脚? [英] How do I remove duplicate word header/footer generated into a word document from asp.net?

查看:87
本文介绍了如何从asp.net删除在Word文档中生成的重复单词页眉/页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码在单词文档中生成单词页眉/页脚:页眉/页脚已正确生成,但也被复制为文档中的第一个文本.我正在寻找一种以编程方式不重复或删除word文档中重复文本的方法.

Response.ContentType =应用程序/msword"
Response.AppendHeader("Content-Disposition","attachment; filename = mytest.doc")%>

Response.Write(" +" +< title>动态生成的文档")

Response.Write(")

Response.Write("@page" +"{size:8.5in 11.0in; mso-footer:f1; mso-header:h1; padding:24.0pt 24.0pt 24.0pt 24.0pt;" +"margin:0.75in 0.50in 0.75in 0.50in;"+" mso-header-margin:.5in;"+" mso-footer-margin:.5in; mso-paper-source:0;}"+" div.Section1"+" {page: Section1;}"+" p.MsoFooter,li.MsoFooter,div.MsoFooter {margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-大小:12.0pt; font-family:"Arial";})

Response.Write("{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:''Arial ";}"+"->"+""+")
Response.Write("

I am generating word header/footer into a word document using the following code: The header/footer is being generated properly but is also duplicated as the first text in the document. I am looking for a way to programmitically not duplicate or to remove the duplicate text in the word document.

Response.ContentType = "application/msword"
Response.AppendHeader("Content-Disposition", "attachment;filename=mytest.doc")%>

Response.Write("" + "" + "<title>Dynamic Generated Document")

Response.Write("")

Response.Write(" @page" + "{size:8.5in 11.0in; mso-footer: f1; mso-header: h1; padding:24.0pt 24.0pt 24.0pt 24.0pt;" + " margin:0.75in 0.50in 0.75in 0.50in ; " + " mso-header-margin:.5in; " + " mso-footer-margin:.5in; mso-paper-source:0;}" + " div.Section1" + " {page:Section1;}" + "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; font-family:''Arial'';}")

Response.Write("{margin:0in; margin-bottom:.0001pt; mso-pagination:widow-orphan; tab-stops:center 3.0in right 6.0in; font-size:12.0pt; font-family:''Arial'';}" + "-->" + "" + "")
Response.Write("

")

Response.Write("
")

Response.Write("
")

Response.Write("MY HEADER"&"
")

Response.Write("
")

Response.Write("MY HEADER" & "
")

Response.Write("
")
Response.Write("MY FOOTER"&
)

Response.Write("
")
Response.Write("MY FOOTER" &
")

Response.Write("

")

推荐答案

我建​​议在Word中创建看起来像您想要的文档将其保存为docx,然后比较XML以查看您的错误之处.
I would suggest creating a document in Word that looks the way you want it to, saving it as a docx, then comparing the XML to see where yours is wrong.


谢谢,我创建了带有页眉和页脚的word doc,如何查看xml ?
Thanks, I created a word doc with a header and footer, how do I view the xml?


如果将扩展名从.docx更改为.zip,您会发现该文件只是一个zip.当您打开它时,xml就在里面.
If you change the extension from .docx to .zip, you will find the file is just a zip. When you open it, the xml is inside.


这篇关于如何从asp.net删除在Word文档中生成的重复单词页眉/页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆