BuiltInTableStyles.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.Drawing
  6. Imports System.IO
  7. Imports System.Linq
  8. Imports GrapeCity.Documents.Word
  9. Imports GrapeCity.Documents.Imaging
  10.  
  11. '' Demo of all built-in table styles
  12. Public Class BuiltInTableStyles
  13. Public Function CreateDocx() As GcWordDocument
  14. Dim rows = 3
  15. Dim cols = 4
  16.  
  17. Dim doc = New GcWordDocument()
  18. Dim pars = doc.Body.Paragraphs
  19.  
  20. pars.Add("Demo of All Built-in Table Styles", doc.Styles(BuiltInStyleId.Title))
  21.  
  22. For Each id In [Enum].GetValues(GetType(BuiltInStyleId))
  23. If id = BuiltInStyleId.User Then
  24. Continue For
  25. End If
  26. Dim style = doc.Styles(id)
  27. If style.Type <> StyleType.Table Then
  28. Continue For
  29. End If
  30.  
  31. pars.Add($"The following table is formatted using style '{style.Name}':")
  32. Dim table = doc.Body.Tables.Add(cols, rows, style)
  33. For row = 0 To rows - 1
  34. For col = 0 To cols - 1
  35. table.Rows(row).Cells(col).GetRange().Paragraphs.First.GetRange().Runs.Add($"Cell ({row},{col})")
  36. Next
  37. Next
  38. Next
  39.  
  40. '' Done:
  41. Return doc
  42. End Function
  43. End Class
  44.