custome XML Parts重复 [英] custome XML Parts duplicates
问题描述
嗨大家我有一个使用内容控件和自定义XML部分生成单词报告的应用程序,
Hi Guys i have an application to generate word reports using content controls and Custom XML parts ,
这里是方案,我有单词2007模板文件,有内部控件定义在名为 1.docx,2.docx 和son on, 我根据报告no 参数点击数据库,然后获取数据然后写一个XMl文件,其中
同名报告否是1.xml,2.xml,基于传递的参数,然后我将docx模板文件的自定义XML部分更新到另一个文件夹,并打开文件
here is the scenario , i have word 2007 template files , have content controls defined inside named 1.docx , 2.docx and son on, i hit the data base based on report no parameter , and get data then write an XMl file with the same name of report no i.e. 1.xml , 2.xml , based on the passed parameter , then i update the custom XML part of the docx template file the copy to another folder , and open the file
这是我的代码
public void UpdateCustomXML(string reportNumber)
{
UpdateXMLFiles(reportNumber);
string templatePath = reportNumber + ".docx";
string custXMLFilePath = reportNumber + ".xml";
string path = System.Windows.Forms.Application.StartupPath + "\\";
using (WordprocessingDocument wdDoc = WordprocessingDocument.Open(templatePath, true))
{
MainDocumentPart mainPart = wdDoc.MainDocumentPart;
// load custom XML
XmlDataDocument custXML = new XmlDataDocument();
custXML.Load(custXMLFilePath);
// get the XML part that needs to be updated
CustomXmlPart custXMLPart = mainPart.CustomXmlParts.ElementAtOrDefault(0);
// update the content of the custom XML part
using (Stream myStream = custXMLPart.GetStream(FileMode.Create))
{
custXML.Save(myStream);
}
}
File.Copy(path + reportNumber + ".docx", path +"\\Reports\\"+ reportNumber + ".docx", true);
System.Diagnostics.Process.Start(path + "\\Reports\\" + reportNumber + ".docx");
}
推荐答案
您好Omar_awwad,
Hi Omar_awwad,
我们正在研究您的问题。响应可能会有一些延迟。感谢您的耐心等待。
We are doing the research about your problem. There might be some delay about the response. Appreciate your patience.
最诚挚的问候,
Best Regards,
这篇关于custome XML Parts重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!