Bug 43015

Summary: HSSFRow.getLastCellNum() works incorrectly.
Product: POI Reporter: Bina Prieto <Bina>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED DUPLICATE    
Severity: major    
Priority: P2    
Version: 3.0-FINAL   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Bina Prieto 2007-08-02 04:34:49 UTC
Performs test:
1.
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet();
HSSFRow row = sheet.createRow((short) 0);
row.createCell((short) 0);
System.out.println("FIRST CELL NUM: " + row.getFirstCellNum()
    + "; " + " LAST CELL NUM: " + row.getLastCellNum());
Console results:
EXPECTED: FIRST CELL NUM: 0;  LAST CELL NUM: 1
OBSERVED: FIRST CELL NUM: 0;  LAST CELL NUM: 0

Java-doc says:
/**
     * gets the number of the last cell contained in this row <b>PLUS ONE</b>. 
     * @return short representing the last logical cell in the row <b>PLUS ONE</
b>, or -1 if the row does not contain any cells.
     */

    public short getLastCellNum()

If we performs this test for sheet that read from file all is ok.
Comment 1 Andrew 2007-08-22 05:07:55 UTC
I think that this bug becomes only when we create and save new Excel file.
When we read file that was saved by Excel evrything works good.(In reply to 
comment #0)
> Performs test:
> 1.
> HSSFWorkbook workbook = new HSSFWorkbook();
> HSSFSheet sheet = workbook.createSheet();
> HSSFRow row = sheet.createRow((short) 0);
> row.createCell((short) 0);
> System.out.println("FIRST CELL NUM: " + row.getFirstCellNum()
>     + "; " + " LAST CELL NUM: " + row.getLastCellNum());
> Console results:
> EXPECTED: FIRST CELL NUM: 0;  LAST CELL NUM: 1
> OBSERVED: FIRST CELL NUM: 0;  LAST CELL NUM: 0
> 
> Java-doc says:
> /**
>      * gets the number of the last cell contained in this row <b>PLUS ONE</
b>. 
>      * @return short representing the last logical cell in the row <b>PLUS 
ONE</
> b>, or -1 if the row does not contain any cells.
>      */
> 
>     public short getLastCellNum()
> 
> If we performs this test for sheet that read from file all is ok.

(In reply to comment #0)
> Performs test:
> 1.
> HSSFWorkbook workbook = new HSSFWorkbook();
> HSSFSheet sheet = workbook.createSheet();
> HSSFRow row = sheet.createRow((short) 0);
> row.createCell((short) 0);
> System.out.println("FIRST CELL NUM: " + row.getFirstCellNum()
>     + "; " + " LAST CELL NUM: " + row.getLastCellNum());
> Console results:
> EXPECTED: FIRST CELL NUM: 0;  LAST CELL NUM: 1
> OBSERVED: FIRST CELL NUM: 0;  LAST CELL NUM: 0
> 
> Java-doc says:
> /**
>      * gets the number of the last cell contained in this row <b>PLUS ONE</
b>. 
>      * @return short representing the last logical cell in the row <b>PLUS 
ONE</
> b>, or -1 if the row does not contain any cells.
>      */
> 
>     public short getLastCellNum()
> 
> If we performs this test for sheet that read from file all is ok.

I think that this bug becomes only when we create and save new Excel file by 
POI.
When we read file that was saved by Excel evrything works good. 
Comment 2 Yegor Kozlov 2008-05-05 07:49:49 UTC

*** This bug has been marked as a duplicate of bug 43901 ***