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

Free Support Forum - aspose.com

NullPointerException in Excel file cell when valid HTML value set using Aspose.Cells for Java


I have simple code

Cell cell = new Workbook().getWorksheets().get(0).getCells().get(“A1”);

cell.setHtmlString("<p><font color="#b01500">Text</font></p>"); // this line work
cell.setHtmlString("<p><b><font color="#b01500">Text</font></b></p>"); // this line throw NullPointerException

Why we can not set second string? Do we have some restriction for string value?



I have tried following code but no exception is observed. Could you please test it again and provide the feedback? The only change which I have made in the sample code is that I have used ‘\’ before the double quotes in the string as given below:

Cell cell = new Workbook().getWorksheets().get(0).getCells().get("A1");
cell.setHtmlString("<p><font color=\"#b01500\">Text</font></p>"); // this line work
cell.setHtmlString("<p><b><font color=\"#b01500\">Text</font></b></p>"); // this line throw NullPointerException

If you still get an issue, please provide us a simplified complete project for our testing. We will test it and provide our feedback after analysis.

Hello. I tried again and still have a problem. I created simple project and will provide it for for you.
Please test it.

asposeNPE.zip (3.7 KB)



I have tried your project using IntelliJ IDEA with Aspose.Cells for Java 19.2.6 but could not observe this issue. Could you please inform which version are you using for testing? You may please try it using latest version and share the feedback.
Aspose.Cells for Java 19.2.6

I am using aspose-cells 18.3 and I have
Exception in thread “main” java.lang.NullPointerException
at com.aspose.cells.zgx.a(Unknown Source)
at com.aspose.cells.zgx.a(Unknown Source)
at com.aspose.cells.Cell.setHtmlString(Unknown Source)
But I tried aspose-cells 19.2 and seems this exception is not reproduceble any more… Seems this problem related only to specific version of aspose-cells…
Thanks, I will use latest version.



Good to know that your issue is sorted out by our latest version/fix. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.