I'm writing a code that finds the desired column in an input sheet and takes the entire column and put it in a different order in an output sheet. Basically I want to take in an Excel file and reorganize it in an output file. The path I've chosen is to find the numerical value of the column and use that to find the cells within each row. I'm getting an error at the line
rdrCell = inputSheet.getRow(placeRow+1).getCell(y);
is there something wrong with the way I'm trying to get the cell value?
for(Iterator<Cell> cit = idRow.cellIterator(); cit.hasNext(); )
{
Cell cell = cit.next();
cell.setCellType(Cell.CELL_TYPE_STRING);
String chr = "Chr";
Row rdrRow = null;
Cell rdrCell = null;
if(chr.equals(cell.getStringCellValue()))
{
int y = cell.getColumnIndex();
for(int placeRow = 0; placeRow<=rowCounter;placeRow++)
{
// error in line below
rdrCell = inputSheet.getRow(placeRow+1).getCell(y);
rdrCell.setCellType(Cell.CELL_TYPE_STRING);
String chrString = rdrCell.getStringCellValue();
Cell chrCell = outputSheet.createRow(placeRow).createCell(0);
chrCell.setCellValue(chrString);
}
}