Class ExcelFileManager

java.lang.Object
com.shaft.tools.io.ExcelFileManager
Direct Known Subclasses:
SHAFT.TestData.EXCEL

public class ExcelFileManager extends Object
  • Constructor Details

    • ExcelFileManager

      public ExcelFileManager(String excelFilePath)
      Creates a new instance of the test data Excel reader using the target Excel file path
      Parameters:
      excelFilePath - target test data Excel file path
  • Method Details

    • getCellData

      public String getCellData(String rowName)
      Reads cell data from the first sheet in the desired Excel workbook Reads cell data using row name (1st column) only Reads cell data from the 2nd column (1st Value in the test data file)
      Parameters:
      rowName - the value of the first cell of the target row
      Returns:
      the value of the target cell within the target row and the second column within the default sheet
    • getCellData

      public String getCellData(String rowName, String columnName)
      Reads cell data from the first sheet in the desired Excel workbook Reads cell data using row name (1st column) and column name
      Parameters:
      rowName - the value of the first cell of the target row
      columnName - the value of the first cell of the target column
      Returns:
      the value of the target cell within the target row and column within the default sheet
    • getCellData

      public String getCellData(String sheetName, String rowName, String columnName)
      Reads cell data from a specific sheet name inside the Excel file Reads cell data using row name (1st column) and column name
      Parameters:
      sheetName - the name of the target Excel sheet
      rowName - the value of the first cell of the target row
      columnName - the value of the first cell of the target column
      Returns:
      the value of the target cell within the target row and column within the target sheet
    • getLastColumnNumber

      public int getLastColumnNumber()
      Returns the last column number that contains a header value (zero based) assuming that you are working within the default sheet. That is if the last column number is 3, it means that there are 4 columns.
      Returns:
      the number of the last column that holds data in the default test data sheet
    • getLastColumnNumber

      public int getLastColumnNumber(String sheetName)
      Returns the last column number that contains a header value (zero based). That is if the last column number is 3, it means that there are 4 columns.
      Parameters:
      sheetName - the name of the target Excel sheet
      Returns:
      the number of the last column that holds data in the target test data sheet
    • getColumnNameUsingRowNameAndCellData

      public String getColumnNameUsingRowNameAndCellData(String sheetName, String rowName, String cellData)
      Looks for the column name that holds the cellData in the specified rowName and sheetName
      Parameters:
      sheetName - the name of the target Excel sheet
      rowName - the value of the first cell of the target row
      cellData - the value of the target cell within the target row
      Returns:
      the value of the first cell of the target column
    • getColumnNameUsingRowNameAndCellData

      public String getColumnNameUsingRowNameAndCellData(String rowName, String cellData)
      Looks for the column name that holds the cellData in the specified rowName and the default sheet name
      Parameters:
      rowName - the value of the first cell of the target row
      cellData - the value of the target cell within the target row
      Returns:
      the value of the first cell of the target column