We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

java.lang.ClassCastException: com.aspose.words.zz1K cannot be cast to com.aspose.words.zz1D

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();
}
}
}
}

@ganeshtech,

To ensure a timely and accurate response, please ZIP and attach the following resources here for testing:

  • Your simplified input Word document you are getting this problem with
  • Please also create a simplified standalone Java application (source code without compilation errors) that helps us to reproduce your current problem on our end and attach it here for testing. Please do not include Aspose.Words JAR files in it to reduce the file size.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.