You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2012/09/15 18:15:09 UTC

[Bug 53877] New: POI 3.8 error attempting to program a "delete columns" capability

https://issues.apache.org/bugzilla/show_bug.cgi?id=53877

          Priority: P2
            Bug ID: 53877
          Assignee: dev@poi.apache.org
           Summary: POI 3.8 error attempting to program a "delete columns"
                    capability
          Severity: normal
    Classification: Unclassified
          Reporter: everymoment@comcast.net
          Hardware: PC
            Status: NEW
           Version: 3.8
         Component: HSSF
           Product: POI

Created attachment 29380
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=29380&action=edit
Demonstrates an error, possibly in HSSFrow.moveCell()

The attached java file POI_error_in_column_deletes.java attempts to demonstrate
one way to program column deletes in POI 3.8. This java program does the
following: 
  - creates a new workbook
  - creates 10 rows each containing 10 empty cells
  - fills in range A3:E3 with "A", "B", "C", "D", and "E"
  - runs code designed to delete columns B and C,
      but instead of getting ADE in the third row it gets ACE
  - outputs a workbook testDeleteColumns.xls

It get the same incorrect result in POI 3.8 and in the
poi-3.9-beta1-20120915.jar nightly.

The inner loop of deleting columns, which contains the error, is the method
deleteColumnFromRow:


/** Removes a cell at START_COL and shifts remainder of row to the left by one.
 * @param row row from which to delete and shift cells
 * @param START_COL index of cell to remove
 */
private static void deleteColumnFromRow(HSSFRow row, final int START_COL){
    if(START_COL >= COLS){
        return;
    }
    HSSFCell check = row.getCell(START_COL);
    if(null!=check){
        row.removeCell(check);
    }
    System.err.println(
        "        deleteColumnFromRow: row = "+
        row.getRowNum());
    HSSFCell cell = null;
    for(int col = START_COL+1; col < COLS; col++){
        int source = col;
        int destination = col-1;
        cell = row.getCell(source);
        if(null != row.getCell(destination)){
            row.removeCell(row.getCell(destination));
            // Because the API says the destination cannot exist,
            // the destination has been deleted. The API reference is
            //
poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFRow.html
        }
        if(null != cell){
            // I THINK THE ERROR MIGHT BE IN moveCell().
            row.moveCell(cell,(short)(destination));
        }
    }
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53877] POI 3.8 error attempting to program a "delete columns" capability

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53877

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
When I run your test-program with the latest trunk-version of poi I get A D E
correctly, it seems the bug was fixed at some point. Please reopen or report a
new bug with updated information if there is still a problem for you with
snapshot builds or the next upcoming release (likely 3.10).

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 53877] POI 3.8 error attempting to program a "delete columns" capability

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=53877

monzarc@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from monzarc@gmail.com ---
I've also had difficulty getting a working 'deleteColumns()' method, and would
very much like to know if a solution is on offer.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org