Independentsoft
Home
Products
Purchase
Support
Downloads
Company
Contact
Word .NET
>
Tutorial
> Get all tables
The example shows you how to retrieve all tables from a document and change border of all tables.
C# example
using System; using Independentsoft.Office; using Independentsoft.Office.Word; using Independentsoft.Office.Word.Tables; namespace Sample { class Program { static void Main(string[] args) { WordDocument doc = new WordDocument("c:\\test.docx"); Table[] tables = doc.GetTables(); foreach (Table table in tables) { table.TopBorder = new TopBorder(StandardBorderStyle.DoubleLine); table.BottomBorder = new BottomBorder(StandardBorderStyle.DoubleLine); table.LeftBorder = new LeftBorder(StandardBorderStyle.DoubleLine); table.RightBorder = new RightBorder(StandardBorderStyle.DoubleLine); table.HorizontalInsideBorder = new HorizontalInsideBorder(StandardBorderStyle.DoubleLine); table.VerticalInsideBorder = new VerticalInsideBorder(StandardBorderStyle.DoubleLine); } doc.Save("c:\\test2.docx"); } } }
VB example
Imports System Imports Independentsoft.Office Imports Independentsoft.Office.Word Imports Independentsoft.Office.Word.Tables Module Module1 Sub Main(ByVal args As String()) Dim doc As WordDocument = New WordDocument("c:\test.docx") Dim tables As Table() = doc.GetTables() For Each table As Table In tables table.TopBorder = New TopBorder(StandardBorderStyle.DoubleLine) table.BottomBorder = New BottomBorder(StandardBorderStyle.DoubleLine) table.LeftBorder = New LeftBorder(StandardBorderStyle.DoubleLine) table.RightBorder = New RightBorder(StandardBorderStyle.DoubleLine) table.HorizontalInsideBorder = New HorizontalInsideBorder(StandardBorderStyle.DoubleLine) table.VerticalInsideBorder = New VerticalInsideBorder(StandardBorderStyle.DoubleLine) Next doc.Save("c:\\test2.docx") End Sub End Module