We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Reading a Date Value From a Worksheet


Im trying to read a DATE value from a .xlsx file using aspose.I used the getValue() method of com.aspose.Cells class.It returns the date value in the format yyyy-mm-ddThh:mm:ss.Is this the Default DateTime Format that will be returned always.Can I configure the Format by anymeans.

I need the date to be returned in the format dd-mm-yy hh:mm:ss (and some other format and that depends on the situation).

Is there any way that I can specify the Date Format that should be returned.

Thanks in Advance.

This message was posted using Page2Forum from /community/public/documentation


Well, by default, the DateTime values are based on your regional and locale settings on your machine.
Well, you need to specify your desired DateTime by using style.setCustom() method (applying the custom string you want) to be set properly for your needs, see the document for your reference:

Thank you.

Please see the sample code below for your reference:

Sample code:

//Instantiating a Workbook object
Workbook workbook = new Workbook();

Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();

//Adding the current system date to "A1" cell
Cell cell = cells.get("A1");

//Setting the display format of the custom date
Style style = cell.getStyle();
style.setCustom("dd-mm-yy hh:mm:ss");


Output Console:
21-05-13 18:39:11 - OK
21-05-13 18:39:11 - OK