See attached workbook
In Aspose.Cells 2.4.3 I do a getStringValue( ) on cell B77 of asttached workbook and get a "0" result. I expected "01-01-2011" as a result of a string formula. All identical cells above B77 (like cell B71) give the right result, all identical cells below (like B83, B89) give the wrong result. When loading the sheet in Excel, everything seems to be correct. What can be wrong?
Used Java code:
System.out.println( workbook.getWorksheets().getActiveSheet().getCells().getCell( 2, 77 ).getStringValue() );
Regards,
Wim Roeling
Hi Wim,
Thanks for reporting.
The row and column index starts from 0, so if you want to retrieve the value of B77, it means, you will look at the cell present at columnIndex=1 and rowIndex=76
So your correct code will be like this.
System.out.println( workbook.getWorksheets().getActiveSheet().getCells().getCell( 76, 1 ).getStringValue() );
Yes, you are right, but this is not the problem. In my code it's done correctly in a loop. By mistake I typed (2,77) in this examples where I should have typed (1,76).
Nevertheless it goes wrong in cell B77 and all identical cells below.
What it wrong here?
Thnx, Wim Roeling
Hi,
You are right, I can see the problem.
Well, the cell73 is considered as string and cell77 is considered as numeric by Aspose.Cells for Java that’s why the problem occurs.We will fix it soon.
This issue has been logged as CELLSJAVA-26081.
Hi,
Please call Workbook.calculateFormula() method before retrieving the values from the cells. I have tested with the following sample code using your template file and it works fine.
Sample code:
Workbook workbook=new Workbook();
workbook.open(“test2strange.xls”);
Worksheet sheet=workbook.getWorksheets().getSheet(0);
workbook.calculateFormula();
Cell cellB73=sheet.getCells().getCell(“B73”); //="01-01-2012"
Cell cellB77=sheet.getCells().getCell(“B77”); //="01-01-2010"
Cell cellB83=sheet.getCells().getCell(“B83”); //="01-01-2010"
Cell cellB89=sheet.getCells().getCell(“B89”); //="01-01-2010"
System.out.println(cellB73.getStringValue()); //OK
System.out.println(cellB77.getStringValue()); //OK
System.out.println(cellB83.getStringValue()); //OK
System.out.println(cellB89.getStringValue()); //OK
Thank you.
Hi Amjad,
You are right. I have closed this issue now.
Thanks a lot. Works perfectly now. You guys are great!