[英]Passing values from List to MS-Word table
我有一個存儲在列表中的值列表。 我需要將所有列表值傳遞給MS-Word中的表。 該表還應根據列表大小增長。 我正在Windows窗體C#中實現這一點。
希望我能從你身邊得到想法。
提前致謝.. :)
List<string> YourList = new List<string>();
//fill your list
object oMissing = System.Reflection.Missing.Value;
// get your table or create a new one like this
// the number '2' is the rows number
Microsoft.Office.Interop.Word.Table myTable = oWordDoc.Add(myRange, 2,numberOfColumns)
int rowCount = 2;
//add a row for each item in a collection.
foreach( var s in YourList)
{
myTable.Rows.Add(ref oMissing)
// do somethign to the row here. add strings etc.
myTable.Rows.[rowCount].Cells[1].Range.Text = "Content of column 1";
myTable.Rows[rowCount].Cells[2].Range.Text = "Content of column 2";
myTable.Rows[rowCount].Cells[3].Range.Text = "Content of column 3";
//etc
}
我希望這有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.