我在C#中使用OPENXML編輯doc文件,並希望將其保存。進行了更改,但該文件無法保存。當我打開文件時,它不顯示任何更改。我用跟隨代碼做了它。問題與節省doc文件
using (WordprocessingDocument doc = WordprocessingDocument.Open(source, true))
{
using (StreamReader reader = new StreamReader(doc.MainDocumentPart.GetStream()))
{
documentText = reader.ReadToEnd();
}
Body body = doc.MainDocumentPart.Document.Body;
documentText = documentText.Replace("##date##", "02/02/2014");
documentText = documentText.Replace("##saleno##", "2014");
documentText = documentText.Replace("##Email##", "abc");
documentText = documentText.Replace("##PhoneNo##", "9856321404");
doc.MainDocumentPart.Document.Save();
doc.Close();
}
請幫忙。 謝謝。
是不是好些了嗎? – Stilgar 2014-11-25 09:35:21
是的,在我看來它現在更有用了。不要忘記,鏈接有時可以打破的,如果你只提供一個鏈接,然後回答有危險它可以在未來成爲無用 – musefan 2014-11-25 09:36:39
是的,非常感謝 – 2014-11-25 10:52:53