itext表的外部边框

时间:2010-05-12 15:53:51

标签: c# itext

有没有办法让表格内的单元格没有边框但只有外部边框?

类似的东西:

 ______________
| cell 1   c2  |  
|              |
|______________|

我正在谈论iTextSharp Pdf库

1 个答案:

答案 0 :(得分:0)

一个简单的解决方案是将单元格的边框宽度设置为0.0f,并更改第一行的顶部边框宽度,最后一行的底部边框宽度以及第一列和最后一列的相同内容(分别带左右边框)

(java中的代码,但应该具有意义):

for ( int x = 1, x <= xmax; x++){
   for ( int y = 1, y <= ymax; y++){
      // create the cell
      PdfPCell cell = new PdfPCell(pr);
      cell.setBorderWidth(0.0f);
      cell.setBorderColorBottom(Color.LIGHT_GRAY);
      // ... set the content of the cell here
      // and change the border(s) width
      if (x == 0)
         cell.setBorderWidthLeft(0.1f);
      if (x==xmax)
         cell.setBorderWidthRight(0.1f);
      if (y==0)
         cell.setBorderWidthTop(0.1f);
      if (y==ymax)
         cell.setBorderWidthBottom(0.1f);
      table.addCell(cell);
   }
}

此致