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

Free Support Forum - aspose.com

Aspose Cells getStringValue for DateTime type giving undesired value

When I try to get the string value of Date Time,

in excel the data looks like - 2/15/2016
while reading the cell value using getValue - 2016-02-15T00:00:00
while reading the cell value using getStringValue- 2?15?

So how will I get the String Value whatever displayed in the cell. We are using aspose-cells-8.4.1.jar file

Hi,


Please try our latest version/fix: Aspose.Cells for Java v8.7.0.2

If you still find the issue with v8.7.0.2, kindly provide us your template file and sample code to reproduce the issue on our end.

Thank you.

Thank you for replying asap. Tried with latest jar


Code Snippet:
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
Cell cellA1 = cells.get(“A1”);
Cell cellB1 = cells.get(“B1”);
//A1 - 2/11/2016 9:01:00 PM
//B1 - 2/11/2016
System.out.println("Cell A1 getDisplayStringValue - " + cellA1.getDisplayStringValue());
System.out.println("Cell B1 getDisplayStringValue - " + cellB1.getDisplayStringValue());
System.out.println("Cell A1 getStringValue - " + cellA1.getStringValue());
System.out.println("Cell B1 getStringValue - " + cellB1.getStringValue());
System.out.println("Cell A1 getValue - " + cellA1.getValue());
System.out.println("Cell B1 getValue - " + cellB1.getValue());

Output:
Cell A1 getDisplayStringValue - 2/11/2016 21:01:00
Cell B1 getDisplayStringValue - 2?11?
Cell A1 getStringValue - 2/11/2016 21:01:00
Cell B1 getStringValue - 2?11?
Cell A1 getValue - 2016-02-11T21:01:00
Cell B1 getValue - 2016-02-11T00:00:00

Hi,


Thanks for the sample code segment.

Please also provide your template file containing your DateTime values and formatting set on A1 and B1 cell, so we could evaluate your issue properly.

Thank you.

Thanks for your quick reply. Here by I have attached the .xlsx file.

Hi,


Thanks for the template file.

Could you also give us your regional or locale settings on your system, we will evaluate your issue soon.

Thank you.

Region - India

Timezone - UTC +5:30

Hi,

Thanks for providing us further details.

After an initial test, I observed the issue as you mentioned. I found that Cell.getStringValue for DateTime type is giving undesired value as you pointed out. I even tried to set the region/locale but to no avail.

e.g
Sample code:

//Set the default locale 
Locale.setDefault(new Locale(“in”, “INDIA”, “WIN”)); 
Workbook workbook = new Workbook(“Book.xlsx”); 
//workbook.getSettings().setRegion(CountryCode.INDIA); 
Worksheet worksheet = workbook.getWorksheets().get(0); 
Cells cells = worksheet.getCells(); 
Cell cellA1 = cells.get(“A1”); 
Cell cellB1 = cells.get(“B1”); 
//A1 - 2/11/2016 9:01:00 PM 
//B1 - 2/11/2016 
System.out.println("Cell A1 getDisplayStringValue - " + cellA1.getDisplayStringValue()); 
System.out.println("Cell B1 getDisplayStringValue - " + cellB1.getDisplayStringValue()); 
System.out.println("Cell A1 getStringValue - " + cellA1.getStringValue()); 
System.out.println("Cell B1 getStringValue - " + cellB1.getStringValue()); 
System.out.println("Cell A1 getValue - " + cellA1.getValue()); 
System.out.println("Cell B1 getValue - " + cellB1.getValue()); 

Output:
Cell A1 getDisplayStringValue - 2/11/2016 21:01:00
Cell B1 getDisplayStringValue - 2?11?
Cell A1 getStringValue - 2/11/2016 21:01:00
Cell B1 getStringValue - 2?11?
Cell A1 getValue - 2016-02-11T21:01:00
Cell B1 getValue - 2016-02-11T00:00:00

I have logged a ticket with an id “CELLSJAVA-41737” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

Thank you.

Thank you very much for your quick support.

Hi,

Thanks for using Aspose.Cells.

It is to inform you that we have fixed your issue CELLSJAVA-41737 now. We will soon provide the fix after performing QA and including other enhancements and fixes.

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


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Appreciate for your timely help. Thank you very much to Aspose Cells Team.

Hi,


Good to know that your issue is sorted out by the new version/fix. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.

Thank you.