Bug 43015 - HSSFRow.getLastCellNum() works incorrectly.
Summary: HSSFRow.getLastCellNum() works incorrectly.
Status: RESOLVED DUPLICATE of bug 43901
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.0-FINAL
Hardware: All All
: P2 major (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-02 04:34 UTC by Bina Prieto
Modified: 2008-05-05 07:49 UTC (History)
0 users



Attachments

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