poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 43901] Last cell number in row is set incorrectly
Date Thu, 06 Mar 2008 16:46:35 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=43901


Richard Evans <richard.evans@datanomic.com> changed:

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




--- Comment #7 from Richard Evans <richard.evans@datanomic.com>  2008-03-06 08:46:35
PST ---
I agree with the functionality of getLastCellNum().  The specification is fine
for me.

However the original report was that XLS files _written_ by POI have the wrong
value for getLastCellNum().  If you write an XLS with three columns, then read
it back, getLastCellNum() returns 2 not 3.  

If you read a XLS file with three columns generated by Excel, getLastCellNum()
returns 3 as expected.

See the original attachment with this issue.

Our temporary workround was to modify HSSFRow.addCell to read:

    /**
     * used internally to add a cell.
     */

    private void addCell(HSSFCell cell)
    {
        short column=cell.getCellNum();
        if (row.getFirstCol() == -1)
        {
            row.setFirstCol(column);
        }
        if (row.getLastCol() == -1)
        {
            row.setLastCol((short) (column + 1));
        }

        if(column>=cells.length)
        {
          HSSFCell[] oldCells=cells;
          int newSize=oldCells.length*2;
          if(newSize<column+1) newSize=column+1;
          cells=new HSSFCell[newSize];
          System.arraycopy(oldCells,0,cells,0,oldCells.length);
        }
        cells[column]=cell;

        if (column < row.getFirstCol())
        {
            row.setFirstCol(column);
        }
        if (column >= row.getLastCol())
        {
            row.setLastCol((short) (column + 1));
        }
    }


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- 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


Mime
View raw message