Problem in getting string value of cell

Hi,

I’m trying to get the content of an excel worksheet and “copy” it to a word document.
I am using the ConverterXls2Doc written by Alexey (from Aspose.word support).

But when reading some cells (that are formatted as currency cell), I get this error message :

Exception in thread “main” java.lang.IllegalArgumentException: Malformed pattern “#,##0.00’ '€40”
at java.text.DecimalFormat.applyPattern(Unknown Source)
at java.text.DecimalFormat.(Unknown Source)
at com.aspose.cells.b.a.o.a(Unknown Source)
at com.aspose.cells.aR.b(Unknown Source)
at com.aspose.cells.aR.c(Unknown Source)
at com.aspose.cells.aR.a(Unknown Source)
at com.aspose.cells.aR.a(Unknown Source)
at com.aspose.cells.Cell.getStringValue(Unknown Source)
at ConverterXls2Doc.GetTextFromCell(ConverterXls2Doc.java:911)
at ConverterXls2Doc.ImportExcelCell(ConverterXls2Doc.java:276)
at ConverterXls2Doc.GetTablePart(ConverterXls2Doc.java:229)
at ConverterXls2Doc.GetTablePartsArray(ConverterXls2Doc.java:170)
at ConverterXls2Doc.Convert(ConverterXls2Doc.java:92)
at ConverterXls2Doc.main(ConverterXls2Doc.java:1370)

How can I fix it ?

I have attached the code of the converter and the xls file that triggers the error.

My understanding is that when getting the string value of the cell, the code detects that the value is double. It the tries to apply the format #,##0.00 (with java.text.DecimalFormat class) but the pattern contains somewhere a currency symbol and it fails). Is it that ? If yes, what is the workaround ? else, what is happening and how can I fix it ?

Thank you for your help !

Boris

Hi,

I guess, it might be a bug of the logic, however, if you think it is a bug of Aspose.Cells for Java, then please provide us a simplified code to replicate the issue. You can use hardcoded values and you can manually generate xlsx/xls file using Ms-Excel and use it instead. It will be better if you remove all the Aspose.Words code. In case, you could not remove it completely, then please provide me the link to download your version of Aspose.Words for Java.

Also, you should test it with the latest version:
Aspose.Cells for Java v7.0.1.3

Please note when you use this version, make sure you are using all the needed Java libraries which you can get from the main zip file: Aspose.Cells for Java 7.0.1

Thank you for your answer !

I can reproduce the problem without any word code. Please find in attachment the code tor reproduce the problem with the XLS file used to get the exception.

I will give a try with the latest version of Aspose.cells and will post the result.

Boris

I have tested with the latest version you have pointed me out and the behavior is the same on my machine.

Can you reproduce the problem ?

Boris

Hi Boris,

Thanks for sorting out the problem. I have further narrowed it down to this code and replicate the problem.

I used the latest version:
Aspose.Cells for Java v7.0.1.3


Exception:
Exception in thread “main” java.lang.IllegalArgumentException: Malformed pattern “#,##0.00’ '€40”
at java.text.DecimalFormat.applyPattern(Unknown Source)
at java.text.DecimalFormat.(Unknown Source)
at com.aspose.cells.b.a.o.a(Unknown Source)
at com.aspose.cells.aT.b(Unknown Source)
at com.aspose.cells.aT.c(Unknown Source)
at com.aspose.cells.aT.a(Unknown Source)
at com.aspose.cells.aT.a(Unknown Source)
at com.aspose.cells.Cell.getStringValue(Unknown Source)
at ClsAsposeTest.f1(ClsAsposeTest.java:56)
at ClsAsposeTest.main(ClsAsposeTest.java:15)

We have logged this issue in our database. We will fix it and let you know asap.

This issue has been logged as CELLSJAVA-30971.

Java


String path = “F:\Shak-Data-RW\Downloads\excel-document-test-aspose.xls”;


Workbook book = new Workbook(path);


int rowIndex = 29;

int columnIndex = 5;


com.aspose.cells.Cell excelCell = book.getWorksheets().get(0).getCells().get(rowIndex, columnIndex);


String str = excelCell.getStringValue();



Hi,

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

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


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