Hi
I added a custome key to get the excel file , sheet name , row indexx and column index :
> @Keyword
//###### read data from excel sheet in files file , fileName should be in filename.xlsx format
def readDataFromExcel(String fileName,int sheetIndex, int rowNum, int cellNum){
String pathToApp = RunConfiguration.getProjectDir() + ("\\files\\")+(fileName)
FileInputStream file = new FileInputStream (new File(pathToApp))
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(sheetIndex);
String Data_fromCell=sheet.getRow(rowNum).getCell(cellNum).getStringCellValue();
return Data_fromCell
}
it works perfectly for index
but I want to call column through headers names , tried the following but it is not working :
@Keyword
def readDataFromExcel1(String fileName,String sheetName, int rowNum, String cellName){
String pathToApp = RunConfiguration.getProjectDir() + ("\\files\\")+(fileName)
FileInputStream file = new FileInputStream (new File(pathToApp))
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheet(sheetName);
int colIdx = CellReference.convertColStringToIndex(cellName);
String Data_fromCell = CellUtil.getCell(rowNum, colIdx);
}
Please describe how it is not working.
What value you gave for the parameters fileName, sheetName, rowNum, cellName?
What did you expected as returned value?
What value did you get actually?
Any error messages in the Console?
fileName : Borrower data - Copy.xlsx (inside katalon file foldere)
sheetName : ‘Borrower’ the first sheet on the excel file
rowNum : 0
cellName : Carol (located at 0 row , 1 column)
expected to pass row index and column name to get the cell value for example : row 7 , column Carol the value is carol@gmail.com
the error in getcell method , and convertColStringToIndex is returning a bug number 104606 but seems its converting the name to ASCI or sth else