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





--- Comment #8 from Josh Micich <[EMAIL PROTECTED]>  2008-03-06 11:33:44 PST ---
(In reply to comment #7)
> 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.  

You are right. Interestingly, if you re-save that file from Excel,
getLastCellNum() returns 3, as expected.  So something is definitely wrong.

To reproduce the bug you don't even need to write-out/read-back the workbook. 
You can just call getLastCellNum() after adding a cell:

    public void testLastCellNumIsCorrectAfterAddCell_bug43901(){
        HSSFWorkbook book = new HSSFWorkbook();
        HSSFSheet sheet = book.createSheet("test");
        HSSFRow row = sheet.createRow(0);

        // New row has last col -1
        assertEquals(-1, row.getLastCellNum());
        if(row.getLastCellNum() == 0) {
            fail("Identified bug 43901");
        }

        // Create two cells, will return one higher
        //  than that for the last number
        row.createCell((short) 0);
        assertEquals(1, row.getLastCellNum());
        row.createCell((short) 255);
        assertEquals(256, row.getLastCellNum());
    }

// 
It seems like there are a few related problems ( moving and removing cells
too).  I'll upload a patch shortly to fix all of these.


-- 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to