欢迎来到天天文库
浏览记录
ID:20068659
大小:57.00 KB
页数:3页
时间:2018-10-08
《结合eventhanlder和openxml 实现上传word文档加页眉,页脚》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、结合eventHanlder和openXMl实现上传word文档加页眉,页脚 先要引用entFormat.OpenXml 其他不多说,直接贴代码usingSystem;usingSystem.Security.Permissions;usingSystem.Runtime.InteropServices;usingMicrosoft.SharePoint;usingSystem.IO;usingSystem.IO.Packaging;usingDocumentFormat.OpenXml.Packaging;usingSystem.X
2、ml;usingSystem.Collections.Generic; namespaceAddHeaderFooterReceiver{ publicclassAddHeaderFooterEventReceiver:SPItemEventReceiver { publicstringGetFooter() { stringfooterVal=<?xmlversion=1.0encoding=UTF-8standalone=yes?><lns:ve=office/l><lvers
3、ion=1.0encoding=UTF-8standalone=yes?><lns:ve=office/l><w:pw:rsidR=00C8737Aw:rsidRDefault=00C8737A><w:pPr><w:pStylew:val=Header/></w:pPr><w:r><w:t>hello</w:t></w:r></w:p><w:pw:rsidR=00C8737Aw:rsidRDefault=00
4、C8737A><w:pPr><w:pStylew:val=Header/></w:pPr></w:p></w:hdr>; r1234下一页——..,。eturnheaderVal; } publicvoidode.Internal,headerRelationshipType); stringrelID=rel.Id; NameTablent=neeTable(); XmlNamespaceMana
5、gernsManager=nelNamespaceManager(nt); nsManager.AddNamespace(lNamespace); XmlDocumentx=nelDocument(nt); x.Load(umentPart.GetStream()); XmlNodetargetNode=x.SelectSingleNode(//lNodeListheaderNodes=targetNode.SelectNodes(./.Xml.XmlNodeheaderNode
6、inheaderNodes) { targetNode.RemoveChild(headerNode); } XmlElementnode=x.CreateElement(lNamespace); XmlAttributeattr=node.Attributes.Append(x.CreateAttribute(r:id,relationshipNamespace)); attr.Value=relID; no
7、de.Attributes.Append(attr); targetNod上一页1234下一页——..,。e.InsertBefore(node,targetNode.FirstChild); } x.Save(umentPart.GetStream(FileMode.Create,FileAccess.ode.Internal,footerRelationshipType); stringrelID=rel.Id; NameTablent=ne
8、eTable(); XmlNamespaceManagernsManager=nelNamespaceManager(nt); nsManager.AddNames
此文档下载收益归作者所有