tags:

views:

129

answers:

1

Hi, Is there any way to not have borders for cells inside a table but have the external border only?

Something like:

 ______________
| cell 1   c2  |  
|              |
|______________|

I;m talking about iTextSharp Pdf library

A: 

Hello,

A simple solution would be to set the border width of the cells to 0.0f, and change the top border width for the first row, the bottom border width for the last one, and the same thing for first and last columns (with left and right border respectively)

(code in java, but should convoy the meaning) :

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);
   }
}

Regards,

PATRY