Class ExcelParserHelper

java.lang.Object
org.qubership.atp.mia.utils.ExcelParserHelper

public class ExcelParserHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    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.XSSFCell
    getCell(int rowNumber, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet)
    Gets Cell in row and column.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getCellAnyway(int rowNumber, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet)
    Gets Cell in row and column.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getCellByHeaderNameInRow(String headerName, int headerRowNum, org.apache.poi.xssf.usermodel.XSSFRow row)
    Gets Cell by header name in row.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getCellByHeaderNameInRow(String headerName, org.apache.poi.xssf.usermodel.XSSFRow row)
    Gets Cell by header name in row.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getCellByParentAndChildHeadersInRow(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.XSSFCell
    getCellByPattern(String pattern, int columnNumber, org.apache.poi.xssf.usermodel.XSSFSheet sheet)
    Gets Cell by column number and pattern.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getCellByPatternInRange(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 String
    getCellValue(org.apache.poi.ss.usermodel.Cell cell)
    Gets cell value.
    static String
    getCellValue(org.apache.poi.xssf.usermodel.XSSFCell cell)
    Gets cell value.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getHeaderByCell(int headerRowNum, org.apache.poi.xssf.usermodel.XSSFCell cell)
    Gets Cell header of the provided Cell.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getHeaderByPattern(String pattern, int headerRowNum, org.apache.poi.xssf.usermodel.XSSFSheet sheet)
    Gets header by pattern.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getHeaderByPattern(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.XSSFCell
    getHeaderByPattern(String pattern, org.apache.poi.xssf.usermodel.XSSFSheet sheet)
    Gets header by pattern in Row 0.
    static org.apache.poi.xssf.usermodel.XSSFCell
    getHeaderByPatternInRange(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.XSSFSheet
    getSheet(Path path, String sheetName)
    Gets sheet of excel file.
    static org.apache.poi.xssf.usermodel.XSSFSheet
    getSheet(org.apache.poi.xssf.usermodel.XSSFWorkbook workbook, String sheetName)
    Gets sheet of excel file.
    static org.apache.poi.xssf.usermodel.XSSFSheet
    getSheet(ExcelWorkbook workbook, String sheetName)
     
    Gets workbook.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 name
      row - 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 name
      headerRowNum - row number of header
      row - 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 header
      cell - 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 header
      sheet - 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 header
      headerRowRange - header row range
      sheet - 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 header
      headerRowNum - header row number
      sheet - 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 pattern
      headerRowNum - header row number
      sheet - sheet
      range - 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 name
      parentHeaderRowNum - parent header row number
      childHeaderName - childheader name
      childHeaderRowNum - child eader row number
      row - 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 - pattern
      columnNumber - column number
      sheet - 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 number
      columnNumber - column number
      sheet - 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 number
      columnNumber - column number
      sheet - 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 - pattern
      columnNumber - column number
      rowRange - row range
      sheet - 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 - pattern
      columnNumber - column number
      sheet - 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 - pattern
      columnNumber - column number
      rowRange - row range
      sheet - 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 - pattern
      columnNumber - column number
      startRowNumber - start row number
      sheet - 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

      @Nonnull public static ExcelWorkbook getWorkBook(@Nonnull String path)
      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 - workbook
      sheetName - 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 file
      sheetName - sheet name
      Returns:
      sheet of excel file
      Throws:
      IllegalArgumentException - in case problem with file or sheet
    • getCellValue

      @Nonnull public static String getCellValue(@Nullable org.apache.poi.ss.usermodel.Cell cell)
      Gets cell value.
      Parameters:
      cell - cell
      Returns:
      cell value
    • getCellValue

      @Nonnull public static String getCellValue(@Nullable org.apache.poi.xssf.usermodel.XSSFCell cell)
      Gets cell value.
      Parameters:
      cell - cell
      Returns:
      cell value
    • decimalFormat

      public static String decimalFormat(Double value)
      Gets decimal format.
      Parameters:
      value - value
      Returns:
      decimal format of double