Represents a table with rows, columns and cells.

For a list of all members of this type, see Table Members


System.Object
   ceTe.DynamicPDF.PageElement
      ceTe.DynamicPDF.PageElements.RotatingPageElement
public class Table : RotatingPageElement, IArea, ICoordinate

Remarks

This class can be used to create tables. A table must contain at least one Column and one Row with at least one Cell in that Row. Formatting of each cell in the table is done in a hierarchical manner in that a Cell's formatting take precedent over a Row's formatting which in term takes precedent over a Table's formatting . The column object contains no formatting information. Using the Tables GetOverflowColumns and GetOverflowRows methods you can allow your table to easily flow onto other pages.

Example

The following example will display a simple table on the page.

[Visual Basic]
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.PageElements

Module MyModule
        
    Sub Main()
        
        ' Create a PDF Document
        Dim MyDocument As Document = New Document 
        
        ' Create a Page and add it to the document
        Dim MyPage As Page = New Page
        MyDocument.Pages.Add(MyPage)

        ' Create a table 
        Dim MyTable As Table = New Table(0, 0, 600, 600)

        ' Add columns to the table
        MyTable.Columns.Add(150)
        MyTable.Columns.Add(90)
        MyTable.Columns.Add(90)
        MyTable.Columns.Add(90)

        ' Add rows to the table and add cells to the rows
        Dim row1 As Row = MyTable.Rows.Add(40, ceTe.DynamicPDF.Font.HelveticaBold, _
            16, Color.Black, Color.Gray)
        row1.Align = TextAlign.Center
        row1.VAlign = VAlign.Center
        row1.Cells.Add("Header 1")
        row1.Cells.Add("Header 2")
        row1.Cells.Add("Header 3")
        row1.Cells.Add("Header 4")

        Dim row2 As Row = MyTable.Rows.Add(30)
        Dim cell1 As Cell = row2.Cells.Add("Rowheader 1", Font.HelveticaBold, 16, _
            Color.Black, Color.Gray, 1)
        cell1.Align = TextAlign.Center
        cell1.VAlign = VAlign.Center
        row2.Cells.Add("Item 1")
        row2.Cells.Add("Item 2")
        row2.Cells.Add("Item 3")

        Dim row3 As Row = MyTable.Rows.Add(30)
        Dim cell2 As Cell = row3.Cells.Add("Rowheader 2", Font.HelveticaBold, 16, _
            Color.Black, Color.Gray, 1)
        cell2.Align = TextAlign.Center
        cell2.VAlign = VAlign.Center
        row3.Cells.Add("Item 4")
        row3.Cells.Add("Item 5")
        row3.Cells.Add("Item 6")

        Dim row4 As Row = MyTable.Rows.Add(30)
        Dim cell3 As Cell = row4.Cells.Add("Rowheader 3", Font.HelveticaBold, 16, _
            Color.Black, Color.Gray, 1)
        cell3.Align = TextAlign.Center
        cell3.VAlign = VAlign.Center
        row4.Cells.Add("Item 7")
        row4.Cells.Add("Item 8")
        row4.Cells.Add("Item 9")

        ' Add the table to the page
        MyPage.Elements.Add(MyTable)

        ' Save the PDF
        MyDocument.Draw("C:\MyDocument.pdf")
        
    End Sub
End Module
[C#]
using System;
using ceTe.DynamicPDF;
using ceTe.DynamicPDF.PageElements;

class MyClass
{
    static void Main()
    {
        // Create a PDF Document
        Document document = new Document();

        // Create a Page and add it to the document
        Page page = new Page();
        document.Pages.Add( page );
        
        // Create a table 
        Table table = new Table(0, 0, 600, 600);
        
        //Add columns to the table
        table.Columns.Add( 150 );
        table.Columns.Add( 90 );
        table.Columns.Add( 90 );
        table.Columns.Add( 90 );
        
        // Add rows to the table and add cells to the rows
        Row row1 = table.Rows.Add( 40, Font.HelveticaBold, 16, Color.Black, 
        Color.Gray );
        row1.Align = TextAlign.Center;
        row1.VAlign = VAlign.Center;
        row1.Cells.Add( "Header 1" );
        row1.Cells.Add( "Header 2" );
        row1.Cells.Add( "Header 3" );
        row1.Cells.Add( "Header 4" );
        
        Row row2 = table.Rows.Add( 30 );
        Cell cell1 = row2.Cells.Add( "Rowheader 1", Font.HelveticaBold, 16, 
        Color.Black, Color.Gray, 1 );
        cell1.Align = TextAlign.Center;
        cell1.VAlign = VAlign.Center;
        row2.Cells.Add( "Item 1" );
        row2.Cells.Add( "Item 2" );
        row2.Cells.Add( "Item 3" );
                
        Row row3 = table.Rows.Add( 30 );
        Cell cell2 = row3.Cells.Add( "Rowheader 2", Font.HelveticaBold, 16, 
        Color.Black, Color.Gray, 1 );
        cell2.Align = TextAlign.Center;
        cell2.VAlign = VAlign.Center;
        row3.Cells.Add( "Item 4" );
        row3.Cells.Add( "Item 5" );
        row3.Cells.Add( "Item 6" );
                
        Row row4 = table.Rows.Add( 30 );
        Cell cell3 = row4.Cells.Add( "Rowheader 3", Font.HelveticaBold, 16, 
        Color.Black, Color.Gray, 1 );
        cell3.Align = TextAlign.Center;
        cell3.VAlign = VAlign.Center;
        row4.Cells.Add( "Item 7" );
        row4.Cells.Add( "Item 8" );
        row4.Cells.Add( "Item 9" );
        
        // Add the table to the page
        page.Elements.Add( table );    
        
        // Save the PDF
        document.Draw( @"C:\MyDocument.pdf" );
    }
} 

Requirements

Namespace: ceTe.DynamicPDF.PageElements Namespace

Assembly: DynamicPDF.Generator.[Edition].dll

See Also

Table members | ceTe.DynamicPDF.PageElements Namespace