在文档标题中添加表 [英] Adding table in Document Header
问题描述
我想添加一个第一页标题,显示一个包含2行和3列的表格。我试过的一切都行不通。我最终得到了一个第一页标题,显示了两行文本,与其他页面标题非常不同,但我无法在页面标题中获得
工作表。
有人能给我一个在第一页标题中添加表格的例子吗?
我忘了提到这是在VS2015 C#和office.interop.word 8.5中完成的
谢谢
URW
您好
Hi again,
I want to add a first page header that shows a table of 2 rows and 3 columns. Everything I tried doesn't work. I ended up with a first page header that shows 2 lines of text, that are very different from the other page headers, but I can't get a table to work inside the page header.
Can someone give me an example of adding a table to the first page header?
I forgot to mention that this is done in VS2015 C# and office.interop.word 8.5
Thanks
URW
Hi uwillmore,
please try to refer code below.
it will only add the table in header of the first page.
Add reference to below.
using Office = Microsoft.Office.Core; using Word = Microsoft.Office.Interop.Word;Code:
private void button1_Click(object sender, EventArgs e) { object oMissing = Type.Missing; string fName = @"C:\Users\v-padee\Desktop\demo.docx"; Word._Application oWord = new Word.Application(); Word.Document oDoc = oWord.Documents.Open(fName); oWord.Visible = true; oDoc.PageSetup.DifferentFirstPageHeaderFooter = -1; Word.Range oRange = oDoc.Sections[1].Headers[Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage].Range; Word.Table oTable = oDoc.Tables.Add(oRange, 2, 3, ref oMissing, ref oMissing); oTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleDouble; oTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle; }Output:
Regards
Deepak
这篇关于在文档标题中添加表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!