getTableLevel() method of org.apache.poi.hwpf.usermodel.Paragraph

556 views Asked by At

I am trying to modify the existing code which converts MS word documents to text using apache POI. I am new to this Apache POI API. There is GetTableLevel() method of org.apache.poi.hwpf.usermodel.Paragraph class which returns some integer value.

For some table, this method returns value 1 and for some other tables it returns 0. I am not able to understand this behaviour.

I looked at JavaDoc of this API here but there is no description about the return values of this method.

Can anyone please tell me what are the possible return values of this method?

Here is code snippet which calls the GetTableLevel() method :

for (int x = 0; x < lenParagraph; x++) {
    Paragraph paragraph = range.getParagraph(x);
    int tableLevel = paragraph.getTableLevel();

Please enlighten !!!

2

There are 2 answers

0
JoseK On BEST ANSWER
0
morido On

paragraph.getTableLevel() returns the nesting level (aka "table depth") of a table. For paragraphs which are not part of a table this call always yields 0 - and in addition paragraph.isInTable() will return false. A return value of 1 indicates an ordinary (top level) table. All values n>1 represent a table which is nested n-1 times within another (parent) table.

For more details see [MS-DOC, Section 2.4.3].