Package org.qubership.atp.mia.utils
Class ExcelParserHelper
java.lang.Object
org.qubership.atp.mia.utils.ExcelParserHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringdecimalFormat(Double value) Gets decimal format.static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPattern(String pattern, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all Cells by pattern in column.static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPatternFromRow(String pattern, int columnNumber, int startRowNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all cells by pattern in range.static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPatternInRange(String pattern, int columnNumber, clover.org.apache.commons.lang3.Range<Integer> rowRange, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all cells by pattern in range.static org.apache.poi.xssf.usermodel.XSSFCellgetCell(int rowNumber, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell in row and column.static org.apache.poi.xssf.usermodel.XSSFCellgetCellAnyway(int rowNumber, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell in row and column.static org.apache.poi.xssf.usermodel.XSSFCellgetCellByHeaderNameInRow(String headerName, int headerRowNum, org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by header name in row.static org.apache.poi.xssf.usermodel.XSSFCellgetCellByHeaderNameInRow(String headerName, org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by header name in row.static org.apache.poi.xssf.usermodel.XSSFCellgetCellByParentAndChildHeadersInRow(String parentHeaderName, int parentHeaderRowNum, String childHeaderName, int childHeaderRowNum, org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by parent and child headers in row.static org.apache.poi.xssf.usermodel.XSSFCellgetCellByPattern(String pattern, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell by column number and pattern.static org.apache.poi.xssf.usermodel.XSSFCellgetCellByPatternInRange(String pattern, int columnNumber, clover.org.apache.commons.lang3.Range<Integer> rowRange, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets cell by pattern in range.static clover.org.apache.commons.lang3.Range<Integer> getCellColumnRange(org.apache.poi.xssf.usermodel.XSSFCell cell) Gets range of rows in merged column.static clover.org.apache.commons.lang3.Range<Integer> getCellRowRange(org.apache.poi.xssf.usermodel.XSSFCell cell) Gets range of columns in merged row.static StringgetCellValue(org.apache.poi.ss.usermodel.Cell cell) Gets cell value.static StringgetCellValue(org.apache.poi.xssf.usermodel.XSSFCell cell) Gets cell value.static org.apache.poi.xssf.usermodel.XSSFCellgetHeaderByCell(int headerRowNum, org.apache.poi.xssf.usermodel.XSSFCell cell) Gets Cell header of the provided Cell.static org.apache.poi.xssf.usermodel.XSSFCellgetHeaderByPattern(String pattern, int headerRowNum, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern.static org.apache.poi.xssf.usermodel.XSSFCellgetHeaderByPattern(String pattern, clover.org.apache.commons.lang3.Range<Integer> headerRowRange, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern.static org.apache.poi.xssf.usermodel.XSSFCellgetHeaderByPattern(String pattern, org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern in Row 0.static org.apache.poi.xssf.usermodel.XSSFCellgetHeaderByPatternInRange(String pattern, int headerRowNum, org.apache.poi.xssf.usermodel.XSSFSheet sheet, clover.org.apache.commons.lang3.Range<Integer> range) Gets header by pattern in column Range.static org.apache.poi.xssf.usermodel.XSSFSheetGets sheet of excel file.static org.apache.poi.xssf.usermodel.XSSFSheetGets sheet of excel file.static org.apache.poi.xssf.usermodel.XSSFSheetgetSheet(ExcelWorkbook workbook, String sheetName) static ExcelWorkbookgetWorkBook(String path) Gets workbook.
-
Constructor Details
-
ExcelParserHelper
public ExcelParserHelper()
-
-
Method Details
-
getCellByHeaderNameInRow
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellByHeaderNameInRow(@Nonnull String headerName, @Nonnull org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by header name in row.- Parameters:
headerName- header namerow- row number of cell- Returns:
- Cell by header name in row, NULL if header not found
-
getCellByHeaderNameInRow
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellByHeaderNameInRow(@Nonnull String headerName, int headerRowNum, @Nonnull org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by header name in row.- Parameters:
headerName- header nameheaderRowNum- row number of headerrow- row number of cell- Returns:
- Cell by header name in row, NULL if header not found
-
getHeaderByCell
public static org.apache.poi.xssf.usermodel.XSSFCell getHeaderByCell(int headerRowNum, @Nonnull org.apache.poi.xssf.usermodel.XSSFCell cell) Gets Cell header of the provided Cell.- Parameters:
headerRowNum- row number of headercell- cell- Returns:
- Cell header
-
getHeaderByPattern
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getHeaderByPattern(@Nonnull String pattern, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern in Row 0.- Parameters:
pattern- pattern of headersheet- sheet- Returns:
- header cell, NULL otherwise
-
getHeaderByPattern
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getHeaderByPattern(@Nonnull String pattern, clover.org.apache.commons.lang3.Range<Integer> headerRowRange, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern.- Parameters:
pattern- pattern of headerheaderRowRange- header row rangesheet- sheet- Returns:
- header cell, NULL otherwise
-
getHeaderByPattern
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getHeaderByPattern(@Nonnull String pattern, int headerRowNum, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets header by pattern.- Parameters:
pattern- pattern of headerheaderRowNum- header row numbersheet- sheet- Returns:
- header cell, NULL otherwise
-
getHeaderByPatternInRange
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getHeaderByPatternInRange(@Nonnull String pattern, int headerRowNum, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet, @Nonnull clover.org.apache.commons.lang3.Range<Integer> range) Gets header by pattern in column Range.- Parameters:
pattern- header patternheaderRowNum- header row numbersheet- sheetrange- columns range- Returns:
- Cell if found, NULL otherwise
-
getCellByParentAndChildHeadersInRow
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellByParentAndChildHeadersInRow(@Nonnull String parentHeaderName, int parentHeaderRowNum, @Nonnull String childHeaderName, int childHeaderRowNum, @Nonnull org.apache.poi.xssf.usermodel.XSSFRow row) Gets Cell by parent and child headers in row.- Parameters:
parentHeaderName- parent header nameparentHeaderRowNum- parent header row numberchildHeaderName- childheader namechildHeaderRowNum- child eader row numberrow- row- Returns:
- Cell if parent and child headers found, NULL otherwise
-
getCellByPattern
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellByPattern(@Nonnull String pattern, int columnNumber, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell by column number and pattern.- Parameters:
pattern- patterncolumnNumber- column numbersheet- sheet- Returns:
- Cell if pattern matched in column, NULL otherwise
-
getCell
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCell(int rowNumber, int columnNumber, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell in row and column.- Parameters:
rowNumber- row numbercolumnNumber- column numbersheet- sheet- Returns:
- Cell in row and column
-
getCellAnyway
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellAnyway(int rowNumber, int columnNumber, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets Cell in row and column. Create cell if absent.- Parameters:
rowNumber- row numbercolumnNumber- column numbersheet- sheet- Returns:
- Cell in row and column
-
getCellByPatternInRange
@Nullable public static org.apache.poi.xssf.usermodel.XSSFCell getCellByPatternInRange(@Nonnull String pattern, int columnNumber, @Nonnull clover.org.apache.commons.lang3.Range<Integer> rowRange, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets cell by pattern in range.- Parameters:
pattern- patterncolumnNumber- column numberrowRange- row rangesheet- sheet- Returns:
- Cell pattern found, NULL otherwise
-
getAllCellsByPattern
@Nonnull public static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPattern(@Nonnull String pattern, int columnNumber, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all Cells by pattern in column.- Parameters:
pattern- patterncolumnNumber- column numbersheet- sheet- Returns:
- Cells by pattern in column
-
getAllCellsByPatternInRange
@Nonnull public static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPatternInRange(@Nonnull String pattern, int columnNumber, @Nonnull clover.org.apache.commons.lang3.Range<Integer> rowRange, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all cells by pattern in range.- Parameters:
pattern- patterncolumnNumber- column numberrowRange- row rangesheet- sheet- Returns:
- all cell by pattern, NULL otherwise
-
getAllCellsByPatternFromRow
@Nonnull public static Set<org.apache.poi.xssf.usermodel.XSSFCell> getAllCellsByPatternFromRow(@Nonnull String pattern, int columnNumber, int startRowNumber, @Nonnull org.apache.poi.xssf.usermodel.XSSFSheet sheet) Gets all cells by pattern in range.- Parameters:
pattern- patterncolumnNumber- column numberstartRowNumber- start row numbersheet- sheet- Returns:
- all cell by pattern, NULL otherwise
-
getCellColumnRange
public static clover.org.apache.commons.lang3.Range<Integer> getCellColumnRange(@Nonnull org.apache.poi.xssf.usermodel.XSSFCell cell) Gets range of rows in merged column.- Parameters:
cell- cell- Returns:
- Range of rows in merged column
-
getCellRowRange
@Nonnull public static clover.org.apache.commons.lang3.Range<Integer> getCellRowRange(@Nonnull org.apache.poi.xssf.usermodel.XSSFCell cell) Gets range of columns in merged row.- Parameters:
cell- cell- Returns:
- Range of columns in merged row
-
getWorkBook
Gets workbook.- Parameters:
path- path to Excel file- Returns:
- new ExcelWorkbook object for path given.
-
getSheet
@Nonnull public static org.apache.poi.xssf.usermodel.XSSFSheet getSheet(@Nonnull org.apache.poi.xssf.usermodel.XSSFWorkbook workbook, @Nullable String sheetName) throws IllegalArgumentException Gets sheet of excel file.- Parameters:
workbook- workbooksheetName- sheet name- Returns:
- sheet of excel file
- Throws:
IllegalArgumentException- in case problem with file or sheet
-
getSheet
@Nonnull public static org.apache.poi.xssf.usermodel.XSSFSheet getSheet(@Nonnull ExcelWorkbook workbook, @Nullable String sheetName) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getSheet
@Nonnull public static org.apache.poi.xssf.usermodel.XSSFSheet getSheet(Path path, @Nullable String sheetName) throws IllegalArgumentException Gets sheet of excel file.- Parameters:
path- path to excel filesheetName- sheet name- Returns:
- sheet of excel file
- Throws:
IllegalArgumentException- in case problem with file or sheet
-
getCellValue
Gets cell value.- Parameters:
cell- cell- Returns:
- cell value
-
getCellValue
Gets cell value.- Parameters:
cell- cell- Returns:
- cell value
-
decimalFormat
Gets decimal format.- Parameters:
value- value- Returns:
- decimal format of double
-