[英]C# VSTO Word Addin - need to save the table and retrieving it back to word document
[英]is there a way to select row or column table in Word document VSTO C#?
我在 Word 文檔中有一個表格。 我希望能夠對 select 一行或一列或僅一個單元格或整個表進行修改。 現在我可以 select 完整的表格並修改所有單元格,但我不能 select 單個行或列或單元格。 我無法為此目的創建范圍。 在我的 select 整個表的代碼下方:
if (WordAddIn.Config.ApplicationConfig.TemplateLanguage.ValueToShare == true)
{
for (int i = 1; i <= WordManager.Selection.Tables[1].Rows.Count; i++)
{
for (int j = 1; j <= WordManager.Selection.Tables[1].Columns.Count; j++)
{
...
}
}
else
{ }
}
}
想法?
創建您需要的宏。 查看宏的 VB 調用並在代碼中模仿/使用這些調用。
你必須知道你的表/行/列的索引,但這就是你獲取每個索引的方式。 從那里,您可以編輯、刪除、添加等。
Word.Table myTable = Globals.ThisDocument.Tables[0];
//Get Row
Word.Row myRow = myTable.Rows[0];
//Get Column
Word.Column myCOl = myTable.Columns[0];
//Get Cell
int rowNum = 0;
int colNum = 0;
Word.Cell myCell = myTable.Cell(rowNum, colNum);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.