Note that there are some explanatory texts on larger screens.

plurals
  1. POiTextSharp - Use Colspan with PdfPRow
    primarykey
    data
    text
    <p>I am able to create multiple rows if they contain the same number of columns:</p> <pre><code>table = new PdfPTable(3); var firstRowCell1 = new PdfPCell( new Phrase ("Row 1 - Column 1")); var firstRowCell2 = new PdfPCell( new Phrase ("Row 2 - Column 2")); var firstRowCell3 = new PdfPCell( new Phrase ("Row 3 - Column 3")); PdfPCell[] row1Cells = { firstRowCell1, firstLineRow2, firstRowCell3 }; var row1 = new PdfPRow(row1Cells); table.Rows.Add(row1); var nextRowCell1 = new PdfPCell( new Phrase ("Row 2 - Column 1")); var nextRowCell2 = new PdfPCell( new Phrase ("Row 2 - Column 2")); var nextRowCell3 = new PdfPCell( new Phrase ("Row 2 - Column 3")); PdfPCell[] row2Cells = { nextRowCell1, nextRowCell2, nextRowCell3 }; var row2 = new PdfPRow(row2Cells); table.Rows.Add(row2); </code></pre> <p>This works fine giving me two rows each with three columns.</p> <p><img src="https://i.stack.imgur.com/PCFY3.png" alt="enter image description here"></p> <p>However if I want the first row to just have one long column using Colspan it disappears:</p> <pre><code>var table = new PdfPTable(3); var firstRowCell1 = new PdfPCell(new Phrase("Row 1 - Column 1")); firstRowCell1.Colspan = 3; PdfPCell[] row1Cells = { firstRowCell1 }; var row1 = new PdfPRow(row1Cells); deptHeaderTable.Rows.Add(row1); var nextRowCell1 = new PdfPCell(new Phrase("Row 2 - Column 1")); var nextRowCell2 = new PdfPCell(new Phrase("Row 2 - Column 2")); var nextRowCell3 = new PdfPCell(new Phrase("Row 2 - Column 3")); PdfPCell[] row2Cells = { nextRowCell1, nextRowCell2, nextRowCell3 }; var row2 = new PdfPRow(row2Cells); deptHeaderTable.Rows.Add(row2); </code></pre> <p><img src="https://i.stack.imgur.com/TYFO5.png" alt="enter image description here"></p> <p>There are no errors given it just simply does not render. </p> <p>Additionally, I am aware of table.AddCell which automatically starts a new row when the table column limit is reached for the current row. However, I want to use PdfPRow if at all possible.</p> <p>Any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload