Summary: | [PATCH] Fixes bug when writing dates to excel files w/ 1904 date windowing | ||
---|---|---|---|
Product: | POI | Reporter: | Alex Jacoby <ajacoby> |
Component: | HSSF | Assignee: | POI Developers List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | major | Keywords: | PatchAvailable |
Priority: | P2 | ||
Version: | 3.0-dev | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: |
Fixes bug, adds test cases, adds comments
Test data file for 1900 date windowing Test data file for 1904 date windowing invalid patch new patch added several tests and fixed 1904 start date problem |
Description
Alex Jacoby
2007-10-04 07:03:32 UTC
Created attachment 20918 [details]
Fixes bug, adds test cases, adds comments
Patch effects the follwing files: HSSFCell, HSSFDateUtil, their respective test classes, and the test data files 1900DateWindowing.xls and 1904DateWindowing.xls. I think you forgot to attach xls files :) Created attachment 20936 [details]
Test data file for 1900 date windowing
Sorry -- new to subversion -- I had read that it did binary diffs for updates,
but of course I should have realized they wouldn't be included in a patch file.
Created attachment 20937 [details]
Test data file for 1904 date windowing
I added one cell to each of these files: the first is untouched and is used
just for reading. The new cell is used to write and then read back the value.
need to figure out how to access 1900/1904 property from HSSFCell. sorry from Date function :)) Was thinking about one thing and writing about another If you mean from the HSSFDateUtil class, you need to pass the info as a parameter (DateUtil is just a collection of static methods, so there's no other way for it to know which type of date windowing is being used by its caller.) My patch replicates the same style as the earlier patch which fixed the read error: it passes a boolean use1904windowing parameter to the effected method. No. Some functions are 1900/1904 sensitive. (In reply to comment #9) > No. Some functions are 1900/1904 sensitive. I just double-checked. The only functions which are 1900/04 sensitive have a boolean parameter saying that. (Well, the old one-param versions are in there so they don't break existing code, but they just delegate to the 2-param version and default to 1900 date windowing since it's more common.) We're talking about HSSFDateUtil, right? All methods are static, and its constructor is private. Maybe I'm missing something... the following functions use HSSFDateUtil and need access to 1900/1904 flag org.apache.poi.hssf.record.formula.functions.Date#evaluate, org.apache.poi.hssf.record.formula.functions.Day#evaluate, org.apache.poi.hssf.record.formula.functions.Month#evaluate, org.apache.poi.hssf.record.formula.functions.Year#evaluate month might ignore it but day couldn't because of Excel Day Bug, year couldn't as well. Got it. I hadn't looked in the scratchpad area at all, or compiled it. It looks like org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator is solely responsible for grabbing the numeric value from the cell and sticking it in a NumberEval, so it could also pass along 1900/04 windowing information to the NumberEval if we extended NumberEval to store that info too. Sound doable? Just to confirm: The patch won't *break* any of the existing code. The functions will continue to work as before, always assuming 1900 date windowing (which is probably right in nearly all cases, as long as you aren't on a Mac). It looks like we can fix that in a separate patch. So, anyone want to commit this patch first? Or is there something else I should do? Created attachment 20938 [details]
invalid patch
Looks good to me :) Created attachment 20939 [details]
new patch added several tests and fixed 1904 start date problem
this is the patch to apply, don't forget xls files
Is this patch now final and ready to be committed? Yes -- I believe Pavel and I have both finished working on it. Thanks for this, now committed. |