Bug 44510

Summary: Reading and writing file with Dropdown doesn't work in 3.0.2 anymore
Product: POI Reporter: Michael <michael.hunziker>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal CC: mbp
Priority: P2    
Version: 3.0-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Cell G6 contains a simple dropdown. Reading and writing back to a new xls doesn't work in 3.0.2
svn diff of changes to DVALRecord
tar bz2 of one added test class

Description Michael 2008-02-29 05:46:59 UTC
Created attachment 21602 [details]
Cell G6 contains a simple dropdown. Reading and writing back to a new xls doesn't work in 3.0.2

I'd like to read a simple Excel file containing a dropdown list (data validation) and write it back into a new one. The whole thing worked with POI 3.0.1 but not in
with the new POI revision 3.0.2:

1. Read a simple Excel-file with dropdown:
	InputStream input = MyClass.class.getResourceAsStream(
"simple_dropdown.xls" );
	POIFSFileSystem fs = new POIFSFileSystem( input );
	HSSFWorkbook wb = new HSSFWorkbook(fs);

2. Write the Excel file into another file:
	FileOutputStream out = new FileOutputStream("output.xls");
	wb.write(out);
	out.close();

Now, here's the thing:
- My Excel file only contains a dropdown-list, no further special formatting or other stuff!
- If i do the steps above with POI 3.0.1, the dropdown list still exists
in the output file
- If i do the exact same thing with POI 3.0.2, the dropdown is gone in the output-file. The cell only contains the value which was selected in the input file. The validation rule of the cell is also gone, it is set back to "any value".

Am I doing anything wrong?

Michael
Comment 1 Josh Micich 2008-02-29 14:14:20 UTC
Created attachment 21606 [details]
svn diff of changes to DVALRecord
Comment 2 Josh Micich 2008-02-29 14:15:42 UTC
Created attachment 21607 [details]
tar bz2 of one added test class
Comment 3 Josh Micich 2008-02-29 14:22:52 UTC
The problem was due to a combination of in-line field declaration/initialisations, and using the template pattern during instance initialization.  It's very easy to miss the fact that the field initialisations run _after_ the super constructor, which called fillFields() on the current class first.
Comment 4 Nick Burch 2008-03-03 08:08:18 UTC
Thanks for the patch Josh, applied to svn
Comment 5 Josh Micich 2008-05-15 11:56:41 UTC
*** Bug 45004 has been marked as a duplicate of this bug. ***
Comment 6 Josh Micich 2009-12-30 17:06:41 UTC
Fix was applied in svn r633151