Bug 55081

Summary: [PATCH] Function WEEKNUM is incomplete
Product: POI Reporter: Cédric Walter <cedric.walter>
Component: SS CommonAssignee: POI Developers List <dev>
Status: REOPENED ---    
Severity: enhancement    
Priority: P2    
Version: 3.10-dev   
Target Milestone: ---   
Hardware: All   
OS: All   
Attachments: testcase WeekNumFunctionTestCaseData.xls
patch for missing function WEEKNUM
Add additional sanity check/integration test FormulaEvalTestData.xls
Patch adding the 1-argument version of WeekNum

Description Cédric Walter 2013-06-08 16:26:47 UTC
Created attachment 30413 [details]
testcase WeekNumFunctionTestCaseData.xls

Returns a number that indicates where the week falls numerically within a year.

patch for missing function WEEKNUM

WEEKNUM function is part of Analysis ToolPak add-in.

Testcases in WeekNumFunctionTestCaseData.xls
Written for Java 1.5
Comment 1 Cédric Walter 2013-06-08 16:28:07 UTC
Created attachment 30414 [details]
patch for missing function WEEKNUM
Comment 2 Cédric Walter 2013-06-17 20:12:26 UTC
Created attachment 30453 [details]
Add additional sanity check/integration test FormulaEvalTestData.xls
Comment 3 Niggler 2013-06-18 00:25:35 UTC
Note that WEEKNUM is a built-in function (not part of the analysis tookpak) for Excel 2010/2011 and Excel 2013 (and possibly Excel 2007/2008)
Comment 4 Nick Burch 2013-06-18 22:34:26 UTC
(In reply to Niggler from comment #3)
> Note that WEEKNUM is a built-in function (not part of the analysis tookpak)
> for Excel 2010/2011 and Excel 2013 (and possibly Excel 2007/2008)

That could be fun. Any chance someone could create a simple spreadsheet with Excel 2003, and another with 2013 (both need to be fresh files), both of which make a single use of WEEKNUM? That'll let us confirm if they both write it the same even with the analysis tookpak change
Comment 5 Cédric Walter 2013-10-08 15:19:50 UTC
Patch committed r1530256
Now assert validity of weeknum implemntation with 2 simple spreadsheet (Excel 2003, and another with 2013 - both are fresh files), both of which make a single use of WEEKNUM
Comment 6 Dmitry Vasilenko 2014-09-04 21:26:20 UTC
Please note that implementation is incomplete as it does not handle the default return value for the function. The function works fine if it has 2 arguments (the last being the return type) but fails if the user just use WEEKNUM(cell) and omits the second argument for the return type. 

Regards
Dmitry Vasilenko
Comment 7 Dominik Stadler 2014-10-20 20:02:42 UTC
Update summary to reflect current state of this bug
Comment 9 Javen O'Neal 2017-02-23 17:02:41 UTC
Created attachment 34776 [details]
Patch adding the 1-argument version of WeekNum

This patch is untested. The unit test coverage for WeekNum is currently in Excel files.
test-data/spreadsheet/WeekNumFunctionTestCaseData*.xls