Imports Docs.Word



Public Class Tables_CreateTable
	Friend Shared Function Main1() As Document
		'	Create a new document and get NodeList of first section
		Dim Doc As Document = Document.CreateNew()
		Dim Nodes As NodeList = Doc.Sections(0).Nodes

		'	Create a new table with given rows/cells count
		'	and add one paragraph for each cell in the table
        Dim Table1 As New Table(2, 2, 1)
		Table1.Rows(0).Cells(0).AddParagraph("Paragraph 1")
		Table1.Rows(0).Cells(1).AddParagraph("Paragraph 2")
		Table1.Rows(1).Cells(0).AddParagraph("Paragraph 3")
		Table1.Rows(1).Cells(1).AddParagraph("Paragraph 4")
		'	Add this table to the list of nodes of the first section
		Nodes.Add(Table1)

		'	Add a paragraph that divides two tables
		Nodes.AddParagraph("")

		'	Create two new rows and adds two cells
		'	with given text and width to each row
		'	We use two different approaches to accomplish  this task
		Dim Row1 As New Row()
		Row1.AddCell("Cell 1" & vbCr, 150)
		'	Add a cell with given text
		Row1.AddCell("Cell 2" & vbCr, 150)

		Dim Row2 As New Row()
		Dim Cell_1 As New Cell(150)
		'	Create cell
		Cell_1.AddParagraph("Cell 3-1" & vbCr)
		'	Add content into this cell
		Cell_1.AddParagraph("Cell 3-2" & vbCr)
		Dim Cell_2 As New Cell(150)
		Cell_2.AddParagraph("Cell 4-1" & vbCr)
		Cell_2.AddParagraph("Cell 4-2" & vbCr)
		Row2.Cells.Add(Cell_1)
		Row2.Cells.Add(Cell_2)

		'	Add these rows to the new table
		'	And add this table to the list of nodes of the first section
		Dim Table2 As New Table()
		Table2.Rows.Add(Row1)
		Table2.Rows.Add(Row2)
		Nodes.Add(Table2)

		Return Doc
	End Function
End Class
