【发布时间】:2020-10-07 14:33:45
【问题描述】:
我仍在学习 Migradoc 和 C#,如果我的代码有点冗长,很抱歉,但如果我的表格不适合底部,它会转到下一页,这没关系。但我也注意到它在表格信息和标题(日期、员工、笔记、账单等)之间创建了一条额外的水平线。我已经尝试了一切,从使边界可见性为 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("$62.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: $187.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 之外,我基本上对上面的表有相同的代码。每当我转到新页面时,如何防止标题和表格之间出现多余的水平线?
【问题讨论】: