User-873373993 posted
How to Create two Tables in MS-Word Document using .NET.
I have created one table. but i can't able to create second table.
If i use this second time for 2nd table. 2nd table get created in 1st table's first Cell..
Pls pls help me to create two table in Word documnet
this is for 1st table.
object fileName =
HttpContext.Current.Request.MapPath("Example.doc");
object readOnly =
false;
object isVisible =
true;
object missing = System.Reflection.Missing.Value;
Word.Document oWordDoc;
object start = 1;
object end = 0;
Word.
Table newTable;
Word.Range tableLocation = oWordDoc.Range(ref start,
ref end);oWordDoc.Tables.Add(tableLocation, row, column,
ref missing, ref missing);
newTable = oWordDoc.Tables[1];
for(int row=0; row<2; row++)
{
Word.
Row newRow = oWordDoc.Tables[1].Rows.Add(ref missing);
object count = 1;
int i = 0;
for (int Column = 1; Column <= 2; k++)
{
newRow.Cells[k].Range.Text = table.Rows[row].Cells[i].ToString();
i = i + 1;
oWordApp.Selection.MoveDown(
ref missing,
ref count, ref missing);
}
}