Row and Cell Span

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v4)  /  Re: Row and Cell Span

DynamicPDF Generator for .NET (v4) Forum

 Nov 14 2011 3:36 PM
Is the table heading layout below possible with the Generator?


|------------------------------------------------|
|            |          |       header          |        |
| header | header |----------|----------| header |
|        |           |  header  |  header  |        |
|------------------------------------------------|
 Nov 14 2011 4:51 PM
Posted by a ceTe Software moderator
Hello,

You can set the row and column span values when you add the cell to the CellList. Here is the list of overloads for CellList.Add method and refer to the second and third overloads in the list that takes the integer values of colspan and rowspan.

Thanks,
ceTe Software Support Team.
 Nov 15 2011 11:29 AM
That doesn't work.  The last column does not span the two rows.         

Dim MyTable As Table2 = New Table2(0, 0, 900, 600)

MyTable.CellDefault.Align = TextAlign.Center
MyTable.CellDefault.VAlign = VAlign.Center
MyTable.Border.LineStyle = LineStyle.Solid
MyTable.Border.Width = 0.1

'' Add columns to the table
MyTable.Columns.Add(50) 'Col 1
MyTable.Columns.Add(50) 'Col 2 AND sub col 1
MyTable.Columns.Add(50) 'Col 3 AND sub col 2
MyTable.Columns.Add(50) 'Sub col 3
MyTable.Columns.Add(50) 'Sub col 4
MyTable.Columns.Add(50) 'Total

''Cells that span two rows
'' Add rows to the table and add cells to the rows
Dim rwHeader As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
rwHeader.Cells.Add("Col 1", 1, 3)

Dim rwHeader1 As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
rwHeader1.Cells.Add("Col 2", 2, 1)
rwHeader1.Cells.Add("Col 3", 2, 1)

Dim rwHeader2 As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
rwHeader2.Cells.Add("sub col 1", 1, 1)
rwHeader2.Cells.Add("sub col 2", 1, 1)
rwHeader2.Cells.Add("sub col 3", 1, 1)
rwHeader2.Cells.Add("sub col 4", 1, 1)
rwHeader2.Cells.Add("Total", 1, 2)
 Nov 15 2011 12:44 PM
Posted by a ceTe Software moderator
Hello,

Please try adding the "Total" column to the first row and set the row span to 2. This should work for you. Below is the modified code for it.

        Dim MyTable As Table2 = New Table2(0, 0, 900, 600)

        MyTable.CellDefault.Align = TextAlign.Center
        MyTable.CellDefault.VAlign = VAlign.Center
        MyTable.Border.LineStyle = LineStyle.Solid
        MyTable.Border.Width = 0.1

        '' Add columns to the table
        MyTable.Columns.Add(50) 'Col 1
        MyTable.Columns.Add(50) 'Col 2 AND sub col 1
        MyTable.Columns.Add(50) 'Col 3 AND sub col 2
        MyTable.Columns.Add(50) 'Sub col 3
        MyTable.Columns.Add(50) 'Sub col 4
        MyTable.Columns.Add(50) 'Total

        ''Cells that span two rows
        '' Add rows to the table and add cells to the rows
        Dim rwHeader As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
        rwHeader.Cells.Add("Col 1", 1, 3)

        Dim rwHeader1 As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
        rwHeader1.Cells.Add("Col 2", 2, 1)
        rwHeader1.Cells.Add("Col 3", 2, 1)
        rwHeader1.Cells.Add("Total", 1, 2)

        Dim rwHeader2 As Row2 = MyTable.Rows.Add(0, Font.HelveticaBold, 10, Grayscale.Black, Grayscale.LightGrey)
        rwHeader2.Cells.Add("sub col 1", 1, 1)
        rwHeader2.Cells.Add("sub col 2", 1, 1)
        rwHeader2.Cells.Add("sub col 3", 1, 1)
        rwHeader2.Cells.Add("sub col 4", 1, 1)

Thanks,
ceTe Software Support Team.
 Nov 15 2011 1:19 PM
Aha!  Thanks.  That worked.

All times are US Eastern Standard time. The time now is 12:26 PM.