I just figure out the issue and its working now....Here is the code
private
void button3_Click(object sender, System.EventArgs e)
{
Word.DocumentClass wd =
new Word.DocumentClass();
wd.Activate();
//ADD TEXT
//wd.Content.Text="<table></table>";
//END ADD TEXT
Object start = Type.Missing;
Object end = Type.Missing;
Word.Range rng = wd.Range(
ref start, ref end);
Object defaultTableBehavior = Type.Missing;
Object autoFitBehavior = Type.Missing;
object missing = System.Type.Missing;
//ADD TABLE
Word.Table tbl = wd.Tables.Add
(rng,1, 5,
ref missing, ref missing);
//END ADD TABLE
//SET HEADER
SetHeadings(tbl.Cell(1, 1), "Permit Type");
SetHeadings(tbl.Cell(1, 2), "Completeness Determination");
SetHeadings(tbl.Cell(1, 3), "Draft Permit");
SetHeadings(tbl.Cell(1, 4), "Final Decision");
SetHeadings(tbl.Cell(1, 5), "Other Target");
//END SET HEADER
//ADD ROW
for(int i=0;i<fds.Rows.Count;i++)
{
Word.Row newRow = wd.Tables[1].Rows.Add(
ref missing);
newRow.Range.Font.Bold = 0;
newRow.Range.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphLeft;
newRow.Cells[1].Range.Text = fds.Rows[i][0].ToString();
newRow.Cells[2].Range.Text = fds.Rows[i][1].ToString();
newRow.Cells[3].Range.Text = fds.Rows[i][2].ToString();
newRow.Cells[4].Range.Text = fds.Rows[i][3].ToString();;
newRow.Cells[5].Range.Text = fds.Rows[i][4].ToString();
}
//END ROW
}
//ADD HEADER
static void SetHeadings(Word.Cell tblCell, string text)
{
tblCell.Range.Text = text;
tblCell.Range.Font.Bold = 1;
tblCell.Range.ParagraphFormat.Alignment =
Word.WdParagraphAlignment.wdAlignParagraphCenter;
}
//ADD HEADER