【问题标题】:How to get rid of horizontal line in table when moving to the next page in Migradoc在 Migradoc 中移动到下一页时如何消除表格中的水平线
【发布时间】: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 之外,我基本上对上面的表有相同的代码。每当我转到新页面时,如何防止标题和表格之间出现多余的水平线?

【问题讨论】:

    标签: pdf-generation migradoc


    【解决方案1】:

    我猜你看到的那一行是下一页第一行的上边框。乍一看,这可能没有任何意义。
    水平边框是上一行的下边框和下一行的上边框的组合。而且我认为这种组合是在不考虑分页符的情况下进行的。

    恐怕你无法对出现在那种情况下的这条线做任何事情。但是有一些解决方法。

    但是恕我直言,在第一页的末尾有标题和分隔线而在第二页上有第一个数据是很奇怪的。这可以通过为要保持在一起的行块的第一行设置 KeepWith 来轻松避免。

    另一个选项是将第一行(包括间隔行)标记为标题行。只要表格跳到下一页,标题行就会重复。这也应该防止标题行出现在页面底部而没有任何数据行。

    【讨论】:

    • 我听取了您对第二个选项的建议,它有效!标题从下一页开始,而不是切断它并创建一条水平线。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-01
    • 2020-10-07
    • 2018-01-10
    • 2014-07-10
    • 2019-10-14
    • 1970-01-01
    相关资源
    最近更新 更多