我正在使用NetOffice创建Word文档。
这里几乎没有文档,我正在努力添加一个标题。有人能帮上忙吗?
发布于 2013-07-09 18:02:00
您必须使用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;
}要添加一些文本,请使用:
foreach (Word.Section section in newDocument.Sections)
section.Headers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.Text = "TEST";希望这对进一步的调查有所帮助。
https://stackoverflow.com/questions/17544234
复制相似问题