C# 删除word中的contentControl后删除空行
我有一个word模板,正在尝试在其中编写。我正在使用C# 删除word中的contentControl后删除空行,c#,ms-word,office-interop,C#,Ms Word,Office Interop,我有一个word模板,正在尝试在其中编写。我正在使用ContentControl更改或删除一些文本 我正在使用此代码更改或删除文本 Object oTemplatePath = Server.MapPath("~/DietTemplate/" + template.FileName); oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing); foreach (Cont
ContentControl
更改或删除一些文本
我正在使用此代码更改或删除文本
Object oTemplatePath = Server.MapPath("~/DietTemplate/" + template.FileName);
oWordDoc = oWord.Documents.Add(ref oTemplatePath, ref oMissing, ref oMissing, ref oMissing);
foreach (ContentControl content in oWordDoc.ContentControls)
{
var field = fieldlist.Where(e => e.DietFields.Name == content.Title);
if (field.Single().Value != null)
content.Range.Text = field.Single().Value;
else
content.Delete(true);
}
这将删除内容,但会在其中添加一个空行
我使用此代码而不是“删除”:
oWordDoc.Range( content.Range.Start, content.Range.End).Delete(true);
但是得到了错误
如何删除此空行?重复,仅使用其他语言。我用这个,但有错误。看看我的问题。我可以帮你。查看答案上的所有编辑,其中一个可能对您有所帮助。重复,仅使用其他语言。我用这个,但有错误。看看我的问题。我可以帮你。查看答案上的所有编辑,其中一个可能会对您有所帮助。