setHtmlString throws NullPointer Exception if the String has span tag with style

Hi Team

I was trying to generate an excel workbook with the following code:

public static void main(String[] args) throws Exception{
FileInputStream fis = new FileInputStream(“templatelocation/HelloWorld.xls”);
Workbook workbook = new Workbook(fis);
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet worksheet = worksheets.get(0);
Cells cells = worksheet.getCells();
Cell cell;
cell = cells.get(“A1”);
cell.putValue(“Cell Value”);
cell = cells.get(“A2”);
cell.putValue(“Hello World”);
cell = cells.get(“A3”);
cell.setHtmlString(readString());
workbook.save(savelocation/test1.xls");
}

Please note that the readString() method returns a string like this:

test



I noticed that if the text that is set for the setHtmlString() happens to have style as in the text mentioned above, then aspose throws the following exception. Aspose cells seems to accept only style with DIV tags and not with any other tags. Is there a solution to this problem. We have data coming from various sources such as database, feeds which can contain any tags with style. The following is the exception thrown:

Exception in thread “main” java.lang.NullPointerException
at com.aspose.cells.b.a.o.a(Unknown Source)
at com.aspose.cells.aY.a(Unknown Source)
at com.aspose.cells.aY.a(Unknown Source)
at com.aspose.cells.aY.a(Unknown Source)
at com.aspose.cells.Cell.setHtmlString(Unknown Source)
at org.srini.aspose.cells.AsposeCellValueException.main(AsposeCellValueException.java:26)


In my case the data predominantly had span tags, the work around that I found was replacing span tags with div tags. But this is not a complete solution, there could be other HTML tags with style and that causes a problem.

I have attached the java file along with the template xls and the text file from which the program reads the string.

Thanks a lot. And have a great new Year!
Srini

Hi,

Thank you. Happy New Year to You also.

Please download and use the latest version:

Aspose.Cells for Java 7.0.4
and see if it fixes this problem.

Once, you download the major release from the above link, then update the aspose.cells jar with the latest minor release which you can download from this link:
Aspose.Cells
for Java v7.0.4.2



Hi,


Thanks for the sample code with files.

I can find the issue using your sample code with the template file. You are right, when the Span tag is used it will throw exception. If we use Div tag, it works fine though.

I have logged at ticket with an id: CELLSJAVA-40091. We will soon look into it to figure it out.

Thank you.

Hi,

We have fixed this issue. Please download: Aspose.Cells for Java v7.0.4.5.

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


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