ComponentOne VSView 8.0
Table Formatting

This example shows how to use the TableCell property to create and format a table.

Example Title
Copy Code
With vp

  .StartDoc

 

  ' start table definition

  .StartTable

 

   ' create table with four rows and four columns

    .TableCell(tcCols) = 4

    .TableCell(tcRows) = 4

 

    ' set some column widths (default width is 0.5in)

    .TableCell(tcColWidth, , 1) = "1in"

    .TableCell(tcColWidth, , 2) = "1.3in"

 

    ' assign text to each cell

    Dim r%, c%

    For r = 1 To 4

      For c = 1 To 4

        .TableCell(tcText, r, c) = "Row " & r & " Col " & c

      Next c

    Next r

 

    ' format cell (1,1): make it span two columns, with a

    ' blue background, center alignment, and bold

    .TableCell(tcColSpan, 1, 1) = 2

    .TableCell(tcBackColor, 1, 1) = vbBlue

    .TableCell(tcAlign, 1, 1) = taCenterMiddle

    .TableCell(tcFontBold, 1, 1) = True

 

    ' set row height for row 1

    ' (default height is calculated to fit the contents)

    .TableCell(tcRowHeight, 1) = "0.2in"

 

    ' format cell (3,2): make is span two columns, with a

    ' yellow background, center alignment, and bold

    .TableCell(tcColSpan, 3, 2) = 2

    .TableCell(tcBackColor, 3, 2) = vbYellow

    .TableCell(tcAlign, 3, 2) = taCenterMiddle

    .TableCell(tcFontBold, 3, 2) = True

 

    ' set row height for row 3

    .TableCell(tcRowHeight, 3) = "0.2in"

 

    ' set row borders all around

    .TableBorder = tbAll

 

  ' finish table definition

  .EndTable

  .EndDoc

End With

The above code creates this output:

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback