using System;
using Docs.Word;


namespace SampleManager
{
	class Tables_CreateTable
	{
		internal static Document Main1()
		{
			//	Create a new document and get NodeList of first section
			Document Doc = Document.CreateNew();
			NodeList Nodes = Doc.Sections[0].Nodes;

			//	Create a new table with given rows/cells count
			//	and add one paragraph for each cell in the table
			Table Table1 = 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
			Row Row1 = new Row();
			Row1.AddCell("Cell 1\r", 150);	//	Add a cell with given text
			Row1.AddCell("Cell 2\r", 150);

			Row Row2 = new Row();
			Cell Cell_1 = new Cell(150);		//	Create cell
			Cell_1.AddParagraph("Cell 3-1\r");	//	Add content into this cell
			Cell_1.AddParagraph("Cell 3-2\r");
			Cell Cell_2 = new Cell(150);
			Cell_2.AddParagraph("Cell 4-1\r");
			Cell_2.AddParagraph("Cell 4-2\r");
			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
			Table Table2 = new Table();
			Table2.Rows.Add(Row1);
			Table2.Rows.Add(Row2);
			Nodes.Add(Table2);

			return Doc;
		}
	}
}