1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| object missing = System.Reflection.Missing.Value;
object ReadOnly = false;
Word.Document doc = wordApp.Documents.Open(@"C:\test\test.docx", ref missing, ref ReadOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
wordApp.Visible = true;
string[] textes = new string[6];
textes[0] = "a"; textes[1] = "b"; textes[2] = "c"; textes[3] = "d"; textes[4] = "e"; textes[5] = "f";
for (int i = 0; i < textes.Length; i++)
{
for (int row = 2; row <= doc.Tables[1].Rows.Count; row++)
{
var cell = doc.Tables[1].Cell(row, 1);
cell.Range.Text = (textes[i]).ToString();
}
} |
Partager