Bug 65165

Summary: [DateValue] DATEVALUE should throw an EvaluationException
Product: POI Reporter: Petr Michálek <michalek.petr>
Component: SS CommonAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: Patch to DateValue.java

Description Petr Michálek 2021-03-04 16:32:27 UTC
Created attachment 37754 [details]
Patch to DateValue.java

In case of wrong input parameters DateValue function breaks formula evaluation.
Patch is attached, please review.
Comment 1 Jakub 2021-04-21 17:51:30 UTC
The patch is needed, if the DateTimeException is not caught it stops evaluation completely. 

However I'm not sure that the ErrorEval.NUM_ERROR as suggested in the proposed patch is the right error code to return. My excel (version 2010) returns ErrorEval.VALUE_INVALID. Same for the case where the text argument is blank or an empty string. 

Also maybe the code can be made simple if we catch the DateTimeException in the existing try block?
Comment 2 Dominik Stadler 2021-04-27 06:19:20 UTC
Can you also provide a small unit-test which verifies this to ensure it stays in-place in the future?
Comment 3 PJ Fanning 2021-07-28 16:57:08 UTC
applied fix using r1891858