views:

435

answers:

1

Hello all together,

I try to make a table like this:

PdfPTable Table = new PdfPTable(6);

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("b", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("c", Font1));
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("d", Font1));
Cell.Colspan = 2;
Table.AddCell(Cell);

That works fine. But changing the number of columns will destory the table. Is it a bug or do I make something wrong?

This code destroys the table:

PdfPTable Table = new PdfPTable(17);

PdfPCell Cell = new PdfPCell(new Phrase("a", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 2;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("b", Font1));
Cell.Rowspan = 2;
Cell.Colspan = 10;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("c", Font1));
Cell.Colspan = 5;
Table.AddCell(Cell);

Cell = new PdfPCell(new Phrase("d", Font1));
Cell.Colspan = 5;
Table.AddCell(Cell);

Edit: The table should have this layout:

|-------------------------------------------------------|
| Cell "a" with | Cell "b" with | Cell "c", colspan = 5 |
| colspan = 2   | colspan = 10  |-----------------------|
| rowspan = 2   | rowspan = 2   | Cell "d", colspan = 5 |
|-------------------------------------------------------|

Best regards, Matthias

A: 

add

Table.CompleteRow(); as last line.

Bhavani