Package com.shaft.tools.io
Class ExcelFileManager
java.lang.Object
com.shaft.tools.io.ExcelFileManager
- Direct Known Subclasses:
SHAFT.TestData.EXCEL
-
Constructor Summary
ConstructorDescriptionExcelFileManager
(String excelFilePath) Creates a new instance of the test data Excel reader using the target Excel file path -
Method Summary
Modifier and TypeMethodDescriptiongetCellData
(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)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 namegetCellData
(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 namegetColumnNameUsingRowNameAndCellData
(String rowName, String cellData) Looks for the column name that holds the cellData in the specified rowName and the default sheet namegetColumnNameUsingRowNameAndCellData
(String sheetName, String rowName, String cellData) Looks for the column name that holds the cellData in the specified rowName and sheetNameint
Returns the last column number that contains a header value (zero based) assuming that you are working within the default sheet.int
getLastColumnNumber
(String sheetName) Returns the last column number that contains a header value (zero based).
-
Constructor Details
-
ExcelFileManager
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
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
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 rowcolumnName
- 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
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 sheetrowName
- the value of the first cell of the target rowcolumnName
- 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
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 sheetrowName
- the value of the first cell of the target rowcellData
- the value of the target cell within the target row- Returns:
- the value of the first cell of the target column
-
getColumnNameUsingRowNameAndCellData
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 rowcellData
- the value of the target cell within the target row- Returns:
- the value of the first cell of the target column
-