BuiltInTableStylesHelpers.vb
C# VB
'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''Imports System.Collections.GenericImports System.LinqImports GrapeCity.Documents.Word
Public Class BuiltInTableStylesHelpers Function CreateDocx() As GcWordDocument Dim rows = 3 Dim cols = 4
Dim doc = New GcWordDocument() Dim pars = doc.Body.Paragraphs
pars.Add("Demo of All Built-in Table Styles", doc.Styles(BuiltInStyleId.Title))
For Each id As BuiltInStyleId In System.Enum.GetValues(GetType(BuiltInStyleId)) If id = BuiltInStyleId.User Then Continue For Dim style = doc.Styles(id) If style.Type <> StyleType.Table Then Continue For
pars.Add($"The following table is formatted using style '{style.Name}':") Dim table = doc.Body.Tables.Add(cols, rows, style) For row As Integer = 0 To rows - 1 For col As Integer = 0 To cols - 1 table.Rows(row).Cells(col).GetRange().Paragraphs.First.AddRun($"Cell ({row},{col})") Next Next Next
Return doc End FunctionEnd Class