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 2014/06/17 16:14:17 UTC

[Bug 56635] New: Wrong getLastCellNum returns wrong result when deleting cells in Excel

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

            Bug ID: 56635
           Summary: Wrong getLastCellNum returns wrong result when
                    deleting cells in Excel
           Product: POI
           Version: 3.10
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: buehlmann@phys.ethz.ch

Created attachment 31722
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31722&action=edit
xls file to examine

The method getLastCellNum for (excel) row 20 returns the correct value (9).
Removing the cell 20:j, shifting cells left, the method getLastCellNum returns
31 instead of 1


Use the following code to test:

import java.io.File;
import java.io.IOException;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

/**
 * 
 */

/**
 * @author simonbue
 *
 */
public class CellCount {


    public CellCount(){
        File excelFile = new File("c:/temp/ETH_template.xls");
        Workbook wb = null;
        try {
            wb = WorkbookFactory.create(excelFile);
        } catch (InvalidFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Sheet sheet = wb.getSheet("samplelist");
        Row row = sheet.getRow(19);
         short minColIx = row.getFirstCellNum();
         short maxColIx = row.getLastCellNum();
         for(short colIx=minColIx; colIx<maxColIx; colIx++) {
           Cell cell = row.getCell(colIx);
           if(cell == null) {
             System.out.println("Cell " + colIx + " is null");
             continue;
           }
             System.out.println("Cell type " + colIx + " is " +
cell.getCellType());           
         }
    }

    /**
     * @param args
     */
    public static void main (String[] args) 
    {
        new CellCount();

    }

}

-- 
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 56635] Wrong getLastCellNum returns wrong result when deleting cells in Excel

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

--- Comment #1 from Simon <bu...@phys.ethz.ch> ---
Created attachment 31723
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31723&action=edit
Test Application

-- 
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 56635] Wrong getLastCellNum returns wrong result when deleting cells in Excel

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

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX
                 OS|                            |All

--- Comment #2 from Nick Burch <ap...@gagravarr.org> ---
POI just reports the value that Excel has stored in the file, Excel doesn't
always do the "sensible" thing especially when it comes to styled but un-used
cells. Not really a lot that POI can do if Excel puts slightly duff info in the
file, sorry

-- 
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 56635] Wrong getLastCellNum returns wrong result when deleting cells in Excel

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

--- Comment #3 from Simon <bu...@phys.ethz.ch> ---
So this means that I have to find my own solution. Might it be possible to
mention this in the documentation as I think this can also confuse others.

-- 
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