Extract only display text from hyperlink paragraph

Hi,

I have a word document with a table only have one column. I have to extract the display text from each cell. For that I am using
cell.text()
Sometimes cell contains hyperlinks. So when i take the text as above, result is starting with HYPERLINK \l " along with bookmark name and then display text. I have only wanted display text. So please kindly help me to extract only displaying text.

Thank you

@Gptrnt In your case you should use Node.toString method. For example see the following code:

Document doc = new Document("C:\\Temp\\in.docx");

Iterable<Cell> cells = doc.getChildNodes(NodeType.CELL, true);
for (Cell c : cells)
{
    System.out.println(c.toString(SaveFormat.TEXT).trim());
}

Hi,
Its working. Thanks for your help :slight_smile:

1 Like