How to get the arg of cell?

if cursor move to a cell of any table, how i can get the current position of it? such as tableIndex,rowIndex and columnIndex ?

I hav table like this:

---------------------------------------------------------
| | A | | | | | | | | | | | | | |
| ------------------------------------------------------
| | | | | | | | | | | | | | | |
| ------------------------------------------------------
| | | | | | | | | | | | | | | B |
|---------------------------------------------------------
| | | | | | | | | | | | | | | |
| ------------------------------------------------------
| | | | | | | | | | | | | | | |
---------------------------------------------------------

i hav tow char[] arrays and i have to get cell A's pos and B's pos to place one char in array to each cell. so how i can get A's pos and B's pos? Thanks a lot.

In Aspose.Word there's no such thing as cursor. Something more or less resemblig cursor is DocumentBuilder.CurrentNode property. Check out the following demo code:

string filename = Application.StartupPath + "\\CellPosition.doc";

Document doc = new Document(filename);

DocumentBuilder builder = new DocumentBuilder(doc);

// get number of sections in the document

int nsections = doc.Sections.Count;

for(int sectionIndex = 0; sectionIndex < nsections; sectionIndex++) {

builder.MoveToSection(sectionIndex);

Section section = doc.Sections[sectionIndex];

// get number of tables in the document

int ntables = section.GetChildNodes(NodeType.Table, true).Count;

for(int tableIndex = 0; tableIndex < ntables; tableIndex++) {

// move to first cell of first row of first table in the document

builder.MoveToCell(tableIndex, 0, 0, 0);

// get table corresponding to chosen cell

Table table = (builder.CurrentNode.ParentNode.ParentNode as Cell).ParentRow.ParentTable;

// get number of rows in the table

int nrows = table.Rows.Count;

for(int rowIndex = 0; rowIndex < nrows; rowIndex++) {

// get number of cells in the row

int ncells = (table.Rows[0] as Row).Cells.Count;

for(int cellIndex = 0; cellIndex < ncells; cellIndex++) {

// move to cell

builder.MoveToCell(tableIndex, rowIndex, cellIndex, 0);

// insert text to the chosen cell

((builder.CurrentNode.ParentNode.ParentNode as Cell).FirstParagraph.Runs[0] as Run).Text = "t" + tableIndex + "r" + rowIndex + "c" + cellIndex;

}

}

}

}

doc.Save(System.IO.Path.GetFileNameWithoutExtension(filename) + "_filled.doc");

Please mind that for the following code to work on your test document you should insert some text (space char for example) into every cell of your table, because currently MoveToCell actually moves to Run object of the Paragraph object of cell. And if there is no text in the cell, then currentCell will be null.

Thank you very much. that's help me too much.