Hi,
Paste code in button click you get your requirement.Don't forget mark as answer.Happy coding.
Object oMissing = System.Reflection.Missing.Value;
Object oTrue = true;
Object oFalse = false;
Microsoft.Office.Interop .Word.Application oWord = new Microsoft.Office.Interop .Word.Application();
Microsoft.Office.Interop .Word.Document oWordDoc = new Microsoft.Office.Interop .Word.Document();
oWord.Visible = true;
oWordDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
Object oBookMarkName = "My_Inserted_Bookmark_On_Template";
oWord.Selection.ParagraphFormat.Alignment = Microsoft.Office.Interop .Word.WdParagraphAlignment.wdAlignParagraphLeft;
oWord.Selection.Font.Bold = (int)Microsoft.Office.Interop .Word.WdConstants.wdToggle;
oWord.Selection.TypeText("Set Code:" + " "+ "Set test:");
oWord.Selection.TypeParagraph();
oWord.Selection.TypeText("Set Description" + " "+ " test Description ");
oWord.Selection.TypeParagraph();
oWord.Selection.TypeParagraph();
Object start = Type.Missing;
Object end = Type.Missing;
Microsoft.Office.Interop.Word.Range rng = oWordDoc.Range(ref start, ref end);
Microsoft.Office.Interop.Word.Table tbl = oWordDoc.Tables.Add(rng, dataGridView1.Rows.Count , dataGridView1 .Columns.Count , ref oMissing, ref oMissing);
Object defaultTableBehavior = Type.Missing;
Object autoFitBehavior = Type.Missing;
object missing = System.Type.Missing;
Microsoft.Office.Interop.Word.Row newRow = oWordDoc.Tables[1].Rows.Add(ref missing);
newRow.Range.Font.Bold = 0;
newRow.Range.ParagraphFormat.Alignment = Microsoft.Office.Interop.Word.WdParagraphAlignment.wdAlignParagraphLeft;
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == dataGridView1.Rows.Count - 1)
MessageBox.Show("Successfully Exported");
else
{
for (int j = 0; j < dataGridView1.Columns.Count; j++)
{
tbl.Cell(i + 1, j + 1).Range.Text = dataGridView1.Rows[i].Cells[j].Value.ToString();
}
}
}
oWord.Selection.TypeParagraph();