We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Move to cell below current cell

So I am using Aspose.Word.DocumentBuilder to go to a particular part of a document. I want to do the following:


If (docBuilder.CurrentParagraph.ParentNode.NodeType = Aspose.Word.NodeType.Cell) Then
docBuilder.MoveToCell( a, b, c, 0)
End If

where a, b, and c are, respectively, the table index, row index, and column index of the current location of docBuilder. The problem is, I do not know, and cannot find any documentation on, how to get these indices. Does any one know or can anyone point me in the right direction?



Thanks for your request. Try to use the following code to get these indexes.

Dim tabIndex As Integer

Dim rowIndex As Integer

Dim cellIndex As Integer

Dim table As Table = Nothing

For Each table In doc.FirstSection.Body.Tables

'get index of current table

tabIndex = doc.FirstSection.Body.Tables.IndexOf(table)

Dim row As Row = Nothing

For Each row In doc.FirstSection.Body.Tables(tabIndex).Rows

'get indext of current row

rowIndex = table.Rows.IndexOf(row)

Dim cell As Cell = Nothing

For Each cell In doc.FirstSection.Body.Tables(tabIndex).Rows(rowIndex).Cells

'get index of current cell

cellIndex = row.Cells.IndexOf(cell)

builder.MoveToCell(tabIndex, rowIndex, cellIndex, 0)

builder.Write(String.Format("Table #{0}; Row #{1}; Cell #{2}", tabIndex.ToString(), rowIndex.ToString(), cellIndex.ToString()))




I hope that it will help you.

Best regards.

This seems to be working. Thanks, Alexey!

这看起来是vb 的写法?
.net core 中要怎么获取当前书签定位的表格索引呢?


谢谢你的询问。 请使用以下代码示例来获取所需的输出。

Dim doc As New Document(MyDir & "Bookmark.doc")
Dim bookmark As Bookmark = doc.Range.Bookmarks("bookmark")
Dim table As Table = CType(bookmark.BookmarkStart.ParentNode.GetAncestor(NodeType.Table),Table)
If (Not (table) Is Nothing) Then
    Console.WriteLine(doc.GetChildNodes(NodeType.Table, true).IndexOf(table))
End If