Table header 单元格有分隔线,其他 header 不改变它们的高度

Table header cell has a breakline and the other headers don't change their height

我在 header 单元格中添加了一个大文本,而 table 的另一个单元格没有改变它们的高度 image。

这是我的 table 的代码,我应该添加什么?

Table tblChcklist = new Table(UnitValue.CreatePercentArray(new float[] { 4, 35, 20, 20, 20 })).SetVerticalAlignment(VerticalAlignment.MIDDLE).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER).UseAllAvailableWidth().SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA, PdfEncodings.WINANSI, false));
tblChcklist.SetKeepTogether(true).SetFontSize(10).SetFixedLayout();
tblChcklist.AddHeaderCell(handler.getCell(2, 1, "No.", TextAlignment.CENTER).SetHorizontalAlignment(iText.Layout.Properties.HorizontalAlignment.CENTER).SetVerticalAlignment(VerticalAlignment.MIDDLE));
tblChcklist.AddHeaderCell(handler.getCell(2, 1, $"Seccion {dtPreguntas.Rows[0]["nombreSeccion"] }", TextAlignment.LEFT).SetBold());
tblChcklist.AddHeaderCell(handler.getCell(0, 0, "Si", TextAlignment.CENTER));
tblChcklist.AddHeaderCell(handler.getCell(0, 0, "No", TextAlignment.CENTER));
tblChcklist.AddHeaderCell(handler.getCell(0, 0, "No Aplica", TextAlignment.CENTER));

这里是handle.getCell方法

public Cell getCell(int rowspan,int colspan,String text, TextAlignment alignment)
{
    Cell cell = new Cell(rowspan,colspan).Add(new Paragraph(text));
    cell.AddStyle(new Style().SetBorderBottom(new SolidBorder(ColorConstants.BLACK,0)));
    cell.AddStyle(new Style().SetBorderTop(new SolidBorder(ColorConstants.BLACK, 0)));
    cell.SetPadding(0);
    cell.SetTextAlignment(alignment);
    cell.SetKeepTogether(true);
    return cell;
}

如果我没理解错的话,你不想看到下面的space(用黄色突出显示):

不过,这不是什么奇怪的space,而是第二行单元格的位置,还没有添加。发生这种情况是因为您添加了行跨度为 2 的第一个(“否”)和第二个(“Seccion...”)单元格,因此它们在两行上都占据了 space。但是,您只添加了 5 个单元格,仅填充了第一行,因此第二个拖曳是空的,因此您会在那里看到一些 space。

所以这里有两个解决方案:要么添加更多单元格(如果您有意),要么不将前两个单元格的行跨度值设置为 2。我相信后者应该是这种情况,因为,如果我了解您分享的代码段,这个大的 rowspan 设置错误。