Bug 46266

Summary: moveCell corrupts the row against further edits
Product: POI Reporter: Brian Showers <brian>
Component: HSSFAssignee: POI Developers List <dev>
Status: NEW ---    
Severity: normal CC: kentmartin, onealj
Priority: P2    
Version: 3.2-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: Example java class which domainstrates the bug.
A patch to address this behavior

Description Brian Showers 2008-11-21 09:58:54 UTC
Created attachment 22913 [details]
Example java class which domainstrates the bug.

There appears to be a bug in the way that Row.moveCell() is implemented.  After moving cells, if you attempt to reuse an index that had previously been moved, other data in the worksheet becomes corrupted.

I've attached a sample java program to demonstrate this.  The example does the following steps:
 1. Create a worksheet with a single row
 2. Create 10 cells in indexes 0 to 9
 3. Move all of those cells one to the right so that
     a. Index 0 is blank
     b. Indexes 1 to 10 are not populated
 4. Create a new cell at index 0
 5. Write out the results to disk.

The resulting file has a problem at index 1.  The file which results is blank at index 1.

I've reproduced this in both 3.2 and 3.5-beta3
Comment 1 Joe Pollard 2009-06-23 13:42:54 UTC
Created attachment 23862 [details]
A patch to address this behavior

I was able to address this bug, and get the OP's test case to work with this patch.

Comment 2 Kent Martin 2009-07-17 14:47:10 UTC
Joe's patch does indeed work.  However, formulas are not updated.