Free Support Forum - aspose.com

Incorrectly formatted time not being output

Hello,


When I run the following code:

public static void main(String[] someArgs) throws Exception
{
Workbook myWorkbook = new Workbook(“test/Test03.xls”);
myWorkbook.getSettings().setCalcMode(CalcModeType.MANUAL);

System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 0).getStringValue());
System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 1).getStringValue());

myWorkbook.calculateFormula();

System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 0).getStringValue());
System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 1).getStringValue());
}

on the attached spreadsheet (see xls attachment) which contains in cell A1 the value ‘-0.340277777777778’ formatted as a time, and in cell B1 the value ‘65432113’ formatted as a date (see png attachment), Aspose does not output anything from cell A1, but outputs a ‘#’ for cell B1. I would have expected (from cell A1) ‘#’ to be output as this would be consistent (with B1) and is also what Excel displays.

Hi,


I think you may may use Cell.getValue() instead of Cell.getStringValue() if it suits your needs because getStringValue will give you the string data that is displaying in the cell in MS Excel.

e.g


Workbook myWorkbook = new Workbook(“Test03.xls”);
myWorkbook.getSettings().setCalcMode(CalcModeType.MANUAL);

System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 0).getValue());
System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 1).getValue());

myWorkbook.calculateFormula();


System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 0).getValue());
System.out.println(myWorkbook.getWorksheets().get(0).getCells().get(0, 1).getValue());


Thank you.