2013-08-05 50 views
4

我可以做一個頭在Migradoc這樣的:與表Migradoc頭

//Create Header 
    Paragraph paragraph = section.Headers.Primary.AddParagraph(); 
    paragraph.AddText("Roto"); 
    paragraph.Format.Font.Size = 9; 
    paragraph.Format.Alignment = ParagraphAlignment.Center; 

我可以做一個簡單的表是這樣的:

// Create the HEADER table for the top of every page 
    this.table = section.AddTable(); 
    this.table.Style = "Table"; 
    this.table.Borders.Color = TableBorder; 
    this.table.Borders.Width = 0.25; 
    this.table.Borders.Left.Width = 0.5; 
    this.table.Borders.Right.Width = 0.5; 
    this.table.Rows.LeftIndent = 0; 

    Column column = this.table.AddColumn("8cm"); 
    column.Format.Alignment = ParagraphAlignment.Center; 

    column = this.table.AddColumn("8cm"); 
    column.Format.Alignment = ParagraphAlignment.Center; 

    // Create the header of the table 
    Row row = table.AddRow(); 
    //row = table.AddRow(); 
    row.HeadingFormat = true; 
    row.Format.Alignment = ParagraphAlignment.Center; 
    row.Format.Font.Bold = true; 
    row.Shading.Color = TableBlue; 

    row.Cells[0].AddParagraph("Rotary"); 
    row.Cells[0].MergeRight = 1; 

    row = table.AddRow(); 
    row.HeadingFormat = true; 
    row.Format.Alignment = ParagraphAlignment.Center; 
    row.Format.Font.Bold = true; 
    row.Shading.Color = TableBlue; 
    row.Cells[0].AddParagraph("Part No.:"); 
    row.Cells[0].Format.Alignment = ParagraphAlignment.Left; 
    row.Cells[1].AddParagraph("Tested by:"); 
    row.Cells[1].Format.Alignment = ParagraphAlignment.Left;    

    row = table.AddRow();  
    row.Cells[0].MergeRight = 1; 

如何獲取表進入標題,所以它出現在每個頁面的頂部?

編輯: 因此使其工作我改變:

this.table = section.AddTable(); 

到:

this.table = section.Headers.Primary.AddTable(); 

回答

12

如果你想擁有的每一頁上相同的標題:
使用section.Headers.Primary.AddTable()代替section.Headers.Primary.AddParagraph()

通過爲表的前n行設置row.HeadingFormat = true;,將此行標記爲標題行。當表增長並分幾頁時,標題行將在每個頁面上重複(但在「正常」頁面主體中,而不是標題區域中)。這是標題行的典型用法。如果您不向表頭添加其他行,HeadingFormat = true將不會產生任何影響。

+0

我發誓我嘗試了幾次,但無法讓它工作。今天早上它的作品! – Jeff