public static int[] getColNameIndex(String colName, int totalCol) throws Exception { int[] colIndex = null; String temp = null, col = null; int j = 0; for (int i = ExcelUtils.getFirstRowNum(); i < totalCol; i++) { temp = ExcelUtils.getCellData(1, i).replace(" ", ""); col = colName.replace(" ", ""); if (temp.equalsIgnoreCase(col)) { j++; } } colIndex = new int[j]; j = 0; for (int i = ExcelUtils.getFirstRowNum(); i < totalCol; i++) { temp = ExcelUtils.getCellData(1, i).replace(" ", ""); col = colName.replace(" ", ""); if (temp.equalsIgnoreCase(col)) { colIndex[j] = i; j++; } } return colIndex; }