您必须使用该Word.Section.Headers属性,在下面的示例中,我在页眉上放置了右对齐的图像
foreach (Word.Section section in newDocument.Sections)
{
string picturePath = @"D:\Desktop\test.png";
section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.InlineShapes.AddPicture(picturePath);
section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphRight;
}
Run Code Online (Sandbox Code Playgroud)
要添加一些文本,请使用:
foreach (Word.Section section in newDocument.Sections)
section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "TEST";
Run Code Online (Sandbox Code Playgroud)
希望这有助于进一步调查。
| 归档时间: |
|
| 查看次数: |
786 次 |
| 最近记录: |