SetHtmlString throws Nullpointer Exception

Hi Team,

This post is regarding the setHtmlString throwing nullpointer Exception. Since the below thread was closed, I thought of creating a new post for this:

setHtmlString throws NullPointer Exception if the String has span tag with style - #3 by amjad.sahi - Free Support Forum - aspose.com

When passing empty tags to aspose cells, the library throws exception:

import java.io.FileInputStream;

import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Style;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.cells.WorksheetCollection;

public class AsposeCellValueException {

public static void main(String[] args) throws Exception{
FileInputStream fis = new FileInputStream(“HelloWorld.xls”);
Workbook workbook = new Workbook(fis);
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.get(0);
worksheet.autoFitRows();

Cells cells = worksheet.getCells();
Cell cell;
cell = cells.get(“A1”);
cell.putValue(“Cell Value”);
cell = cells.get(“A2”);
cell.putValue(“Hello World”);

Style style = new Style();
style.setTextWrapped(true);
cell.setStyle(style);

cell = cells.get(“A3”);
cell.setHtmlString(“< >”);

workbook.save(“D:/outputdirectory/test1.xls”);
}
}

I understand that the library expects < and > instead of < or >. But we have a scenario where the data comes from different source. The previous version of aspose cells that we were using use to handle this scenario with out throwing an exception.

Please share me your thoughts

Best Regards
Srinivas

Hi,

I can find the issue as you have mentioned by using your code with my simplest template XLS file. I have logged a ticket for it with an id: CELLSJAVA-40121. We will look into your issue soon.

Thank you.

Hi,

Please download and try the latest version: Aspose.Cells for Java v7.1.0.3

We have catched the exception when user gives invalid html string.

Hi,

Please download and try this fix:
Aspose.Cells
for .NET v7.1.0.4

The issues you have found earlier (filed as CELLSJAVA-40121) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.