create one
string strFilePath = Server.MapPath("template.docx"); string docOutputPath = @"d:\output.docx"; File.Copy(strFilePath, docOutputPath); using (WordprocessingDocument myDocument = WordprocessingDocument.Open(docOutputPath, true)) { string newXml = "<root>" + "<SdkName>asdf</SdkName>" + "<Version>1.0</Version>" + "</root>"; //AddCustomXMLPart() MainDocumentPart main = myDocument.MainDocumentPart; main.DeleteParts<CustomXmlPart>(main.CustomXmlParts); //add and write new XML part CustomXmlPart customXml = main.AddCustomXmlPart(CustomXmlPartType.CustomXml); using (StreamWriter ts = new StreamWriter(customXml.GetStream())) { ts.Write(newXml); } }
No comments:
Post a Comment
Please Give Your Valuable Comments on this Topic