小编Alb*_*ori的帖子

使用iTextSharp的Rowspan无法正常工作

我正在尝试使用iTextSharp创建一个简单的表,所以要使用C#。目标是一个像这样的表:

问题是,如果我在单元格A上将rowspan设置为2,则iTextSharp不会渲染该rowpanned单元格,这意味着该单元格具有与单元格B相同的高度。这是代码:

    PdfPTable corporateTable = new PdfPTable(2);
    corporateTable.HeaderRows = 1;
    corporateTable.TotalWidth = pdfWidth - 50;

    PdfPCell vCell = new PdfPCell();
    vCell.Border = Rectangle.BOX;
    vCell.Rowspan = 2;
    vCell.Phrase = new Phrase("A", new Font(fontLh, 7f, 1, BaseColor.BLACK));
    corporateTable.CompleteRow();
    corporateTable.AddCell(vCell);


    PdfPCell vCellx = new PdfPCell();
    vCellx.Phrase = new Phrase("B", new Font(fontLh, 7f, 1, BaseColor.BLACK));
    vCellx.Colspan = 3;
    corporateTable.AddCell(vCellx);

    PdfPCell vCell1 = new PdfPCell();
    vCell1.Phrase = new Phrase("C", new Font(fontValue, 7f, 0, BaseColor.BLACK));
    corporateTable.AddCell(vCell1);

    corporateTable.WriteSelectedRows(0, -1, 100f, 100f, writer.DirectContent);
    document.Close();
Run Code Online (Sandbox Code Playgroud)

怎么了?我正在使用最新版本的dll。

c# html-table itext

4
推荐指数
1
解决办法
9274
查看次数

标签 统计

c# ×1

html-table ×1

itext ×1