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: [email protected]
Reporter: [email protected]
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: [email protected]
For additional commands, e-mail: [email protected]