Bug 46266 - moveCell corrupts the row against further edits
Summary: moveCell corrupts the row against further edits
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.2-FINAL
Hardware: PC Windows XP
: P2 normal with 5 votes (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-21 09:58 UTC by Brian Showers
Modified: 2015-10-29 09:02 UTC (History)
2 users (show)



Attachments
Example java class which domainstrates the bug. (3.22 KB, application/octet-stream)
2008-11-21 09:58 UTC, Brian Showers
Details
A patch to address this behavior (861 bytes, patch)
2009-06-23 13:42 UTC, Joe Pollard
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.

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