在 Migradoc 中移动到下一页时如何摆脱 table 中的水平线
How to get rid of horizontal line in table when moving to the next page in Migradoc
我仍在学习 Migradoc 和 C#,如果我的代码有点冗长,我很抱歉,但似乎如果我的 table 不适合底部,它会转到下一页没关系。但我也注意到它在 tables 信息和 headers(日期、员工、备注、账单等)之间创建了一条额外的水平线。我已经尝试了所有方法,从将边框可见性设置为 false 并将整行可见性设置为 false,但它不起作用。这是它的样子:
这是我的代码:
Table timeDetailTable2 = section.AddTable();
timeDetailTable2.Rows.LeftIndent = "-1cm";
timeDetailTable2.Borders.Width = 0.75;
Column column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(2));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(3));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(4.75));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(1));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(1.5));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(3.75));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(2));
column6.Format.Alignment = ParagraphAlignment.Right;
Row row6 = timeDetailTable2.AddRow();
Cell cell6 = row6.Cells[0];
cell6.Format.Font.Size = 9;
cell6.Format.Alignment = ParagraphAlignment.Left;
cell6.Shading.Color = Colors.LightGray;
cell6.MergeRight = 6;
cell6.AddParagraph("Charge To: ADV Integrity / Error Message on Outlook Location: NO NOT USE");
cell6.Format.Font.Bold = true;
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.AddParagraph("Date");
cell6 = row6.Cells[1];
cell6.AddParagraph("Staff");
cell6 = row6.Cells[2];
cell6.AddParagraph("Notes");
cell6 = row6.Cells[3];
cell6.AddParagraph("Bill");
cell6 = row6.Cells[4];
cell6.AddParagraph("Hours");
cell6 = row6.Cells[5];
cell6.AddParagraph("Rate");
cell6 = row6.Cells[6];
cell6.AddParagraph("Ext Amt");
for (int i = 0; i <= 6; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Left.Visible = false;
cell6.Borders.Right.Visible = false;
cell6.Borders.Top.Visible = false;
cell6.Format.Font.Bold = true;
cell6.Format.Font.Size = 9;
}
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.AddParagraph();
cell6.MergeRight = 6;
cell6.Borders.Bottom.Visible = false;
cell6.Row.Borders.Visible = false;
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("04/09/2020");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[1];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("Beed, Jacob");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[2];
cell6.Format.Font.Size = 9;
cell6.Format.Font.Bold = true;
paragraph = cell6.AddParagraph("Service Ticket:");
paragraph.AddFormattedText(" 41466", TextFormat.NotBold);
cell6.AddParagraph();
paragraph2 = cell6.AddParagraph("Summary:");
paragraph2.AddFormattedText(" New e-mail needed please, ASAP", TextFormat.NotBold);
cell6.AddParagraph();
paragraph3 = cell6.AddParagraph("");
paragraph3.AddFormattedText("Created new email address for webinars and assigned exchange online" +
"license. Mailbox will be available shortly.", TextFormat.NotBold);
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[3];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("Y");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[4];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("0.50");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[5];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("125.00");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[6];
cell6.Format.Font.Size = 9;
cell6.AddParagraph(".50");
//adding horizontal line
row5 = timeDetailTable2.AddRow();
row5.Borders.Visible = false;
row6 = timeDetailTable2.AddRow();
for(int i = 0; i <= 5; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Right.Visible = false;
}
cell6 = row6.Cells[5];
cell6.Format.Font.Size = 9;
cell6.MergeRight = 1;
cell6.Format.Alignment = ParagraphAlignment.Right;
cell6.Format.Font.Bold = true;
cell6.AddParagraph("Subtotal: 7.50");
for (int i = 0; i <= 6; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Bottom.Visible = false;
cell6.Borders.Left.Visible = false;
cell6.Borders.Right.Visible = false;
}
除了我将它命名为 timeDetailTable 而不是 Table 类型的 timeDetailTable2 之外,我对上面的 table 基本上使用了相同的代码。每当我转到新页面时,如何防止 header 和 table 之间出现额外的水平线?
我猜你看到的线是下一页第一行的上边框。乍一看这可能没有意义。
水平边框是上面一行的底部边框和下面一行的顶部边框的组合。而且我假设这种组合是在不考虑分页符的情况下进行的。
对于那种情况下出现的这条线,恐怕你真的无能为力。但也有解决方法。
但是恕我直言,第一页末尾有 header 和间隔线,第二页有第一个数据,这很奇怪。通过为要保持在一起的行块的第一行设置 KeepWith,可以轻松避免这种情况。
另一种选择是将第一行(包括间隔行)标记为标题行。只要 table 中断到下一页,标题行就会重复。这也应该防止标题行出现在没有任何数据行的页面底部。
我仍在学习 Migradoc 和 C#,如果我的代码有点冗长,我很抱歉,但似乎如果我的 table 不适合底部,它会转到下一页没关系。但我也注意到它在 tables 信息和 headers(日期、员工、备注、账单等)之间创建了一条额外的水平线。我已经尝试了所有方法,从将边框可见性设置为 false 并将整行可见性设置为 false,但它不起作用。这是它的样子:
这是我的代码:
Table timeDetailTable2 = section.AddTable();
timeDetailTable2.Rows.LeftIndent = "-1cm";
timeDetailTable2.Borders.Width = 0.75;
Column column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(2));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(3));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(4.75));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(1));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(1.5));
column6.Format.Alignment = ParagraphAlignment.Center;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(3.75));
column6.Format.Alignment = ParagraphAlignment.Left;
column6 = timeDetailTable2.AddColumn(Unit.FromCentimeter(2));
column6.Format.Alignment = ParagraphAlignment.Right;
Row row6 = timeDetailTable2.AddRow();
Cell cell6 = row6.Cells[0];
cell6.Format.Font.Size = 9;
cell6.Format.Alignment = ParagraphAlignment.Left;
cell6.Shading.Color = Colors.LightGray;
cell6.MergeRight = 6;
cell6.AddParagraph("Charge To: ADV Integrity / Error Message on Outlook Location: NO NOT USE");
cell6.Format.Font.Bold = true;
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.AddParagraph("Date");
cell6 = row6.Cells[1];
cell6.AddParagraph("Staff");
cell6 = row6.Cells[2];
cell6.AddParagraph("Notes");
cell6 = row6.Cells[3];
cell6.AddParagraph("Bill");
cell6 = row6.Cells[4];
cell6.AddParagraph("Hours");
cell6 = row6.Cells[5];
cell6.AddParagraph("Rate");
cell6 = row6.Cells[6];
cell6.AddParagraph("Ext Amt");
for (int i = 0; i <= 6; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Left.Visible = false;
cell6.Borders.Right.Visible = false;
cell6.Borders.Top.Visible = false;
cell6.Format.Font.Bold = true;
cell6.Format.Font.Size = 9;
}
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.AddParagraph();
cell6.MergeRight = 6;
cell6.Borders.Bottom.Visible = false;
cell6.Row.Borders.Visible = false;
row6 = timeDetailTable2.AddRow();
cell6 = row6.Cells[0];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("04/09/2020");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[1];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("Beed, Jacob");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[2];
cell6.Format.Font.Size = 9;
cell6.Format.Font.Bold = true;
paragraph = cell6.AddParagraph("Service Ticket:");
paragraph.AddFormattedText(" 41466", TextFormat.NotBold);
cell6.AddParagraph();
paragraph2 = cell6.AddParagraph("Summary:");
paragraph2.AddFormattedText(" New e-mail needed please, ASAP", TextFormat.NotBold);
cell6.AddParagraph();
paragraph3 = cell6.AddParagraph("");
paragraph3.AddFormattedText("Created new email address for webinars and assigned exchange online" +
"license. Mailbox will be available shortly.", TextFormat.NotBold);
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[3];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("Y");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[4];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("0.50");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[5];
cell6.Format.Font.Size = 9;
cell6.AddParagraph("125.00");
cell6.Borders.Right.Visible = false;
cell6 = row6.Cells[6];
cell6.Format.Font.Size = 9;
cell6.AddParagraph(".50");
//adding horizontal line
row5 = timeDetailTable2.AddRow();
row5.Borders.Visible = false;
row6 = timeDetailTable2.AddRow();
for(int i = 0; i <= 5; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Right.Visible = false;
}
cell6 = row6.Cells[5];
cell6.Format.Font.Size = 9;
cell6.MergeRight = 1;
cell6.Format.Alignment = ParagraphAlignment.Right;
cell6.Format.Font.Bold = true;
cell6.AddParagraph("Subtotal: 7.50");
for (int i = 0; i <= 6; i++)
{
cell6 = row6.Cells[i];
cell6.Borders.Bottom.Visible = false;
cell6.Borders.Left.Visible = false;
cell6.Borders.Right.Visible = false;
}
除了我将它命名为 timeDetailTable 而不是 Table 类型的 timeDetailTable2 之外,我对上面的 table 基本上使用了相同的代码。每当我转到新页面时,如何防止 header 和 table 之间出现额外的水平线?
我猜你看到的线是下一页第一行的上边框。乍一看这可能没有意义。
水平边框是上面一行的底部边框和下面一行的顶部边框的组合。而且我假设这种组合是在不考虑分页符的情况下进行的。
对于那种情况下出现的这条线,恐怕你真的无能为力。但也有解决方法。
但是恕我直言,第一页末尾有 header 和间隔线,第二页有第一个数据,这很奇怪。通过为要保持在一起的行块的第一行设置 KeepWith,可以轻松避免这种情况。
另一种选择是将第一行(包括间隔行)标记为标题行。只要 table 中断到下一页,标题行就会重复。这也应该防止标题行出现在没有任何数据行的页面底部。