word-contentcontrol

Replacing Text of Content Controls in OpenXML

白昼怎懂夜的黑 提交于 2019-12-02 04:54:09
问题 I have a word file that have multy Rich Text Content Control I want to change text of it. I Use this code . using (WordprocessingDocument theDoc = WordprocessingDocument.Open(docName, true)) { MainDocumentPart mainPart = theDoc.MainDocumentPart; foreach (SdtElement sdt in mainPart.Document.Descendants<SdtElement>()) { SdtAlias alias = sdt.Descendants<SdtAlias>().FirstOrDefault(); if (alias != null) { string sdtTitle = alias.Val.Value; var t = sdt.Descendants<Text>().FirstOrDefault(); t.Text=

Replacing Text of Content Controls in OpenXML

≯℡__Kan透↙ 提交于 2019-12-02 02:44:33
I have a word file that have multy Rich Text Content Control I want to change text of it. I Use this code . using (WordprocessingDocument theDoc = WordprocessingDocument.Open(docName, true)) { MainDocumentPart mainPart = theDoc.MainDocumentPart; foreach (SdtElement sdt in mainPart.Document.Descendants<SdtElement>()) { SdtAlias alias = sdt.Descendants<SdtAlias>().FirstOrDefault(); if (alias != null) { string sdtTitle = alias.Val.Value; var t = sdt.Descendants<Text>().FirstOrDefault(); t.Text="Atul works at Microsoft as a .NET consultant. As a consultant his job is to design, develop and deploy"