We are using Aspose Total Java with the aspose words 19.4 version.
Getting this class cast exception only when we pass merge field value as null,
java.lang.ClassCastException: com.aspose.words.zz1K cannot be cast to com.aspose.words.zz1D
When we pass the merge field value as null:
Here “EPRRJHRR” is the merge field when the value null we change the text to “Delete”
mapData.put(“EPRRJHRR”, emergingPlanRequiredRevenue.getAssetBased().getJohnHancockRequiredRevenue() == null ? “DELETE” : formatPercent(emergingPlanRequiredRevenue.getAssetBased().getJohnHancockRequiredRevenue()));
and in INodeChangingCallback we check for “Delete” text to remove the row
@Override
public void nodeInserted(NodeChangingArgs arg0) throws Exception {
Node node = arg0.getNode();
if (node.getNodeType() == NodeType.RUN) {
Run run = (Run) node;
if (run.getRange().getText().contains(“DELETE”)) {
Row row = (Row) run.getAncestor(NodeType.ROW);
if (row != null) {
row.remove();
}
}
}
}