Skip to main content
daitranthanhoa
Inspiring
July 14, 2015
Answered

How get TableId in Document by FDK?

  • July 14, 2015
  • 4 replies
  • 648 views

My Code get Table, But it not working.

It only can get a Cell has content="FrameMaker Source Item"

This content not exist in my table.


tableId = F_ApiGetId(0, DocId, FP_FirstTblInDoc);

while ( tableId ) {

  firstrowId = F_ApiGetId(DocId, tableId, FP_FirstRowInTbl);

  while ( firstrowId ) {

  cellId = F_ApiGetId(DocId, firstrowId, FP_FirstCellInRow);

    while ( cellId ) {

      cellId = F_ApiGetId(DocId, firstrowId, FP_NextCellInRow);

    }

  firstrowId = F_ApiGetId(DocId, tableId, FP_NextRowInTbl);

  }

  tableId = F_ApiGetId(FV_SessionId, DocId, FP_NextTblInDoc);

  }

  }


How get TableId in Document  by FDK?

This topic has been closed for replies.
Correct answer Russ Ward

diatranthanhoa,

I don't understand your question. But if you are trying to iterate over all cells in every table, you have errors in your code. They are common mistakes. The errors are:

- FP_NextTblInDoc is a property of a table object, not the document

- FP_NextRowInTbl is a property of a row object, not the table

- FP_NextCellInRow is a property of a cell object, not the row

So, I would adjust your code as follows, noting that I did not test this:

tableId = F_ApiGetId(0, DocId, FP_FirstTblInDoc);

while ( tableId ) {

  firstrowId = F_ApiGetId(DocId, tableId, FP_FirstRowInTbl);

  while ( firstrowId ) {

  cellId = F_ApiGetId(DocId, firstrowId, FP_FirstCellInRow);

    while ( cellId ) {

      cellId = F_ApiGetId(DocId, cellId, FP_NextCellInRow);

    }

  firstrowId = F_ApiGetId(DocId, firstrowId, FP_NextRowInTbl);

  }

  tableId = F_ApiGetId(DocId, tableId, FP_NextTblInDoc);

  }

  }

Hope this helps,

Russ

4 replies

Russ WardCorrect answer
Legend
July 15, 2015

diatranthanhoa,

I don't understand your question. But if you are trying to iterate over all cells in every table, you have errors in your code. They are common mistakes. The errors are:

- FP_NextTblInDoc is a property of a table object, not the document

- FP_NextRowInTbl is a property of a row object, not the table

- FP_NextCellInRow is a property of a cell object, not the row

So, I would adjust your code as follows, noting that I did not test this:

tableId = F_ApiGetId(0, DocId, FP_FirstTblInDoc);

while ( tableId ) {

  firstrowId = F_ApiGetId(DocId, tableId, FP_FirstRowInTbl);

  while ( firstrowId ) {

  cellId = F_ApiGetId(DocId, firstrowId, FP_FirstCellInRow);

    while ( cellId ) {

      cellId = F_ApiGetId(DocId, cellId, FP_NextCellInRow);

    }

  firstrowId = F_ApiGetId(DocId, firstrowId, FP_NextRowInTbl);

  }

  tableId = F_ApiGetId(DocId, tableId, FP_NextTblInDoc);

  }

  }

Hope this helps,

Russ

Ch__Efstathios
Inspiring
May 12, 2016

Hi! I use the same code but I want to skip tables from non Body Pages. How can I do that?

Legend
May 12, 2016

Hi Ch, please avoid reviving these old threads for loosely-related followup questions. I realize you are just looking for help, but it makes it difficult to keep things organized for readers and contributors alike. Please refer to your current post for this issue:

How to filter tables from body pages only?

Russ