hi Aspose,
We have a cell with the following conditional format
image.png (4.5 KB)
For a value -1 entered in cell with the above conditional format,
When we use aspose Java api
String buyCellValue = buyCell.getAsposeCell().getStringValueWithoutFormat();- returns “-1.0”
but
buyCell.getIntValue() -> returns null.
The issue is sometimes the getIntValue returns right value and sometimes not. What is the consistent way to extract the integer value from a cell?
This is issue only with -ve values. Able to extract +ve values consistently.
@ksnaspose,
Please note, Cell.getStringValueWithoutFormat() attribute is obsolete and will be removed from the APIs soon. So, you should not use it in the long run.
I have tested using the following sample code with the template file (attached) using our latest version/fix v21.8 (please try it if you are not already using it) and it works fine as expected:
e.g.
Sample code:
Workbook workbook = new Workbook("f:\\files\\Bk_stringvaluewithoutformat1.xlsx");
Cells cells = workbook.getWorksheets().get(0).getCells();
String buyCellValue = cells.get("A1").getStringValueWithoutFormat();//- returns “-1.0”
int intValue = cells.get("A1").getIntValue();
double d = cells.get("A1").getDoubleValue();
String val = cells.get("A1").getStringValue();
Object val1 = cells.get("A1").getValue();
System.out.println(buyCellValue);
System.out.println(intValue);
System.out.println(d);
System.out.println(val);
System.out.println(val1);
Output:
-1.0
-1
-1.0
-1
-1.0
If you still find the issue with latest version, kindly do zip your template file and attach with exact code to show the issue, we will check it soon.
files1.zip (5.8 KB)
We are using Aspose.cells version 19.4.0.0. Is the fix available in that old version? Thanks.
@ksnaspose,
No, I am afraid, we cannot include fixes to older versions. Neither we can evaluate issues using older versions. The fixes are based on latest APIs set only. For your current scenario/case either you can use your existing license with older version of the API, you might have to live with the issue or use your own way to cope with it by yourselves. Alternatively, you can upgrade to latest version and try your scenario/case. If you still find any issue with latest version/fix, you may post us your sample code and template file, we will check and fix it soon.
1 Like
test-template.zip (39.4 KB)
Could you please try with our template and let us know? Thanks.
@ksnaspose,
Yes, it works fine when using latest version with your template file. Here is sample code, I evaluated the issue getting value from I41 cell in the first worksheet:
e.g.
Sample code:
Workbook workbook = new Workbook("f:\\files\\test-template.xlsx");
Cells cells = workbook.getWorksheets().get(0).getCells();
String buyCellValue = cells.get("I41").getStringValueWithoutFormat();//- returns “-1.0”
int intValue = cells.get("I41").getIntValue();
double d = cells.get("I41").getDoubleValue();
String val = cells.get("I41").getStringValue();
Object val1 = cells.get("I41").getValue();
System.out.println(buyCellValue);
System.out.println(intValue);
System.out.println(d);
System.out.println(val);
System.out.println(val1);
Output:
-1.0
-1
-1.0
-1
-1.0