BuiltInTableStyles.vb
''
'' This code is part of GrapeCity Documents for Word samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.Drawing
Imports System.IO
Imports System.Linq
Imports GrapeCity.Documents.Word
Imports GrapeCity.Documents.Imaging

'' Demo of all built-in table styles
Public Class BuiltInTableStyles
    Public Function CreateDocx() As GcWordDocument
        Dim rows = 3
        Dim cols = 4

        Dim doc = New GcWordDocument()
        Dim sec = doc.Body.Sections.First
        Dim pars = sec.GetRange().Paragraphs

        pars.Add("Demo of All Built-in Table Styles", doc.Styles(BuiltInStyleId.Title))

        For Each id In [Enum].GetValues(GetType(BuiltInStyleId))
            If id = BuiltInStyleId.User Then
                Continue For
            End If
            Dim style = doc.Styles(id)
            If style.Type <> StyleType.Table Then
                Continue For
            End If

            pars.Add($"The following table is formatted using style '{style.Name}':")
            Dim table = sec.GetRange().Tables.Add(cols, rows, style)
            For row = 0 To rows - 1
                For col = 0 To cols - 1
                    table.Rows(row).Cells(col).GetRange().Paragraphs.First.GetRange().Runs.Add($"Cell ({row},{col})")
                Next
            Next
        Next

        '' Done:
        Return doc
    End Function
End Class