NestedTableHelpers.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Word

Public Class NestedTableHelpers
    Function CreateDocx() As GcWordDocument
        Dim doc As GcWordDocument = New GcWordDocument()

        doc.Body.AddParagraph("Here is a 5 columns by 3 rows table, with a nested table in cell (2, 2):")
        Dim t = doc.Body.AddTable(New String()() {
            New String() {"row 1, col 1", "row 1, col 2", "row 1, col 3", "row 1, col 4", "row 1, col 5"},
            New String() {"row 2, col 1", "row 2, col 2", "row 2, col 3", "row 2, col 4", "row 2, col 5"},
            New String() {"row 3, col 1", "row 3, col 2", "row 3, col 3", "row 3, col 4", "row 3, col 5"}
        })

        Dim ts1 = doc.Styles.Add("Table Style 1", StyleType.Table)
        For Each border In ts1.Table.Borders
            border.LineStyle = LineStyle.Triple
            border.LineWidth = 0.5F
            border.Color.RGB = Color.Purple
        Next
        t.Style = ts1

        ts1.Table.Borders.InsideHorizontal.LineStyle = LineStyle.Double
        ts1.Table.Borders.InsideVertical.LineStyle = LineStyle.Double
        ts1.Table.Padding.All = 3

        Dim cell = t.Rows(1).Cells(1)
        Dim tn = cell.AddTable()
        cell.GetRange().Paragraphs.First.GetRange().Texts.First.Value = "Cell with nested table."

        tn.Rows.Add("Nested (1,1)", "Nested (1,2)", "Nested (1,3)")
        tn.Rows.Add("Nested (2,1)", "Nested (2,2)", "Nested (2,3)")
        tn.Rows.Add("Nested (3,1)", "Nested (3,2)", "Nested (3,3)")

        Return doc
    End Function
End Class