HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet(); HSSFRow row = sheet.createRow((short) 0); HSSFCell cell = row.createCell((short) 0); cell.setCellNum((short) 1); // I think that I have here the came cell as by cell reference // but cell1 is null reference HSSFCell cell1 = row.getCell((short) 1); short cellNum = cell1.getCellNum(); Run this code. We've got NPE but I think that row.getCell((short) 1); operator should return created cell because we chaged cell number (that means "column" number) and now created cell number is 1! row.getCell((short) 0) should return null now. in cell.setCellNum((short) 1); operator.
HSSFCell.setCellNum() was really just setting things in the raw record, and not touching the row, which is why you were seeing what you were I've deprecated the method, and added a moveCell method to HSSFRow. That ought to work as you'd expect. (It's in svn trunk now)