Free Support Forum - aspose.com

Aspose.Word有没有移动光标或者换行的方法?

我阅读API 中有移动单元格的方法 MoveToCell ,但是需要 tabble 的索引,我应该怎么获取当前书签定位的表格的索引呢?
我的word 模板中有很多表格,位置是不固定的,我需要根据书签定位到表格,然后移动到单元格
C# (.net Core)代码有没有示例?
I read that the API has the method MoveToCell that moves the cell, but I need the index of the tabble, how do I get the index of the table where the bookmark is located? There are many tables in my word template, the location is not fixed, I need to locate the table according to the bookmark, and then move to the cell C# (.net Core) code for example

@MX123bo

Thanks for your inquiry. Please use the following code example to get the desired output.

Document doc = new Document(MyDir + "in.docx");
Bookmark bookmark = doc.Range.Bookmarks["bookmark"];
Table table = (Table)bookmark.BookmarkStart.ParentNode.GetAncestor(NodeType.Table);

if (table != null)
{
    Console.WriteLine(doc.GetChildNodes(NodeType.Table, true).IndexOf(table));
}