Reading nested table content inside a cell

In this scenario, I wanted to read the 3rd column, which has a table inside a cell. If I’m reading this cell using cell.toString(SaveFormat.TEXT).trim(), I’m getting the content in a string format where there are no new line separators. Please help here.

@praveentermgrid You can try specifying PreserveTableLayout flag in TxtSaveOptions:

TxtSaveOptions opt = new TxtSaveOptions();
opt.setPreserveTableLayout(true);
String cellContent = cell.toString(opt).trim();
1 Like

The above code is resulting in null pointer exception, I’m attaching the screenshot of it
Screenshot 2023-11-23 at 3.27.12 PM.png (36.1 KB)

@praveentermgrid I have logged the problem as WORDSNET-26261. We will keep you updated and let you know once it is resolved.

For now, as a workaround, you can use the following code:

TxtSaveOptions opt = new TxtSaveOptions();
opt.setPreserveTableLayout(true);
String cellContent = "";
for (Node n : (Iterable<Node>)cell.getChildNodes(NodeType.ANY, false))
    cellContent += n.toString(opt);

cellContent = cellContent.trim();
1 Like

Thanks a bunch, Alexey.

1 Like

The issues you have found earlier (filed as WORDSNET-26261) have been fixed in this Aspose.Words for Java 24.2 update.