A Table is a Rectangle that contains Cells,
ordered in some kind of matrix.
Namespace: iTextSharp.textAssembly: ITextSharp (in ITextSharp.dll) Version: 4.1.6.0
Syntax
C# |
---|
public class Table : Rectangle, ILargeElement, IElement |
Visual Basic |
---|
Public Class Table _ Inherits Rectangle _ Implements ILargeElement, IElement |
Visual C++ |
---|
public ref class Table : public Rectangle, ILargeElement, IElement |
Remarks
Tables that span multiple pages are cut into different parts automatically.
If you want a table header to be repeated on every page, you may not forget to
mark the end of the header section by using the method EndHeaders().
The matrix of a table is not necessarily an m x n-matrix. It can contain holes
or cells that are bigger than the unit. Believe me or not, but it took some serious
thinking to make this as userfriendly as possible. I hope you wil find the result
quite simple (I love simple solutions, especially for complex problems).
Examples

// Remark: You MUST know the number of columns when constructing a Table. // The number of rows is not important. <STRONG>Table table = new Table(3);</STRONG><STRONG>table.SetBorderWidth(1);</STRONG><STRONG>table.SetBorderColor(new Color(0, 0, 255));</STRONG><STRONG>table.SetPadding(5);</STRONG><STRONG>table.SetSpacing(5);</STRONG> Cell cell = new Cell("header"); cell.SetHeader(true); cell.SetColspan(3); <STRONG>table.AddCell(cell);</STRONG><STRONG>table.EndHeaders();</STRONG> cell = new Cell("example cell with colspan 1 and rowspan 2"); cell.SetRowspan(2); cell.SetBorderColor(new Color(255, 0, 0)); <STRONG>table.AddCell(cell);</STRONG><STRONG>table.AddCell("1.1");</STRONG><STRONG>table.AddCell("2.1");</STRONG><STRONG>table.AddCell("1.2");</STRONG><STRONG>table.AddCell("2.2");</STRONG><STRONG>table.AddCell("cell test1");</STRONG> cell = new Cell("big cell"); cell.SetRowspan(2); cell.SetColspan(2); <STRONG>table.AddCell(cell);</STRONG><STRONG>table.AddCell("cell test2");</STRONG>
Inheritance Hierarchy
System..::..Object
iTextSharp.text..::..Element
iTextSharp.text..::..Rectangle
iTextSharp.text..::..Table
iTextSharp.text..::..Element
iTextSharp.text..::..Rectangle
iTextSharp.text..::..Table