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

Free Support Forum - aspose.com

MoveToCell/Table question

Great product ! I do, however, have a question: I’m trying to iterate over all tables in a document, extract text from some table cells, and to add bookmarks to selected cells in selected tables . Initially, I used a Tables NodeCollection which worked as expected. When trying to add a bookmark, however, I run into the Section problem (I cannot get the sectionNo of the current table and hence cannot set the current section for the MoveToCell method to work).
My question, therefore is how this can be done. I.e. I need to iterate all tables, and - in certain situations (based on cell contents) - I need to add a bookmark ?
Best regards and thanks,

Thanks for your inquiry. You can use IndexOf method to determine index of table inside section and index of section inside document. Please see the following code:

// Get section where table is placed
Section currentSect = (Section)currentTable.GetAncestor(NodeType.Section);
// Get index of current section
int sectIndex = doc.Sections.IndexOf(currentSect);
// Get index of Table in the current section
int tableIndex = currentSect.Body.Tables.IndexOf(currentTable);
// move documentbuilder to the firt cell of first row of current table
builder.MoveToCell(tableIndex, 0, 0, 0);
// Insert bookmark

I hope this could help you.
Best regards,

Excellent ! Thank you very much for a prompt and great response. I rellay appreciate it.
Best regards and thanks,