Creating a Table in Word c#

http://msdn.microsoft.com/en-us/library/aa192483(office.11).aspx

 Word.Table tbl = ThisDocument.Tables[1];
tbl.Range.Font.Size = 8;
tbl.Range.Font.Name = “Verdana”;

Object style = “Table Grid 8”;
tbl.set_Style(ref style);
tbl.ApplyStyleFirstColumn = false;
tbl.ApplyStyleLastColumn = false;
tbl.ApplyStyleLastRow = false;

// Insert header text and format the columns.
tbl.Cell(1, 1).Range.Text = “Name”;

Word.Range rngCell;
rngCell = tbl.Cell(1, 2).Range;
rngCell.Text = “Size”;
rngCell.ParagraphFormat.Alignment = 
    Word.WdParagraphAlignment.wdAlignParagraphRight;

rngCell = tbl.Cell(1, 3).Range;
rngCell.Text = “Modified”;
rngCell.ParagraphFormat.Alignment =
    Word.WdParagraphAlignment.wdAlignParagraphRight;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s