Class PoiUtil

java.lang.Object
de.muehlencord.shared.poi.PoiUtil

public abstract class PoiUtil extends Object
Author:
Joern Muehlencord (joern@muehlencord.de)
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment)
     
    static void
    addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment, int rowCount, int columnCount)
     
    static void
    addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment, int rowCount, int columnCount, boolean commentVisible)
     
    static boolean
    cellEmpty(org.apache.poi.ss.usermodel.Cell cell)
     
    static org.apache.poi.ss.usermodel.Cell
    createOrGetCell(org.apache.poi.ss.usermodel.Row row, int cellNumber, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     
    static boolean
    getBooleanValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, boolean defaultValue)
     
    static LocalDate
    getDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber)
     
    static LocalDate
    getDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean returnDefaultValue, LocalDate defaultValue)
     
    static double
    getDoubleValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber)
     
    static Double
    getDoubleValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, Double defaultValue)
     
    static int
    getIntegerValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber)
     
    static Integer
    getIntegerValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, Integer defaultValue)
     
    static String
    getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber)
     
    static String
    getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean mandatory)
    Returns the string value from the given cell.
    static String
    getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean returnDefaultValue, String defaultValue)
     
    protected static String
    remove characters which often cause troubles in other applications - e.g.
    static void
    setBooleanValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean value, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     
    static void
    setDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, String dateString, String dateFormat, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     
    static void
    setDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, Date date, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     
    static void
    setDoubleValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, Double value, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     
    static org.apache.poi.ss.usermodel.Cell
    setStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, String stringValue, org.apache.poi.ss.usermodel.CellStyle cellStyle)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • cellEmpty

      public static boolean cellEmpty(org.apache.poi.ss.usermodel.Cell cell)
    • createOrGetCell

      public static org.apache.poi.ss.usermodel.Cell createOrGetCell(org.apache.poi.ss.usermodel.Row row, int cellNumber, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • setStringValue

      public static org.apache.poi.ss.usermodel.Cell setStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, String stringValue, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • addCellComment

      public static void addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment)
    • addCellComment

      public static void addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment, int rowCount, int columnCount)
    • addCellComment

      public static void addCellComment(org.apache.poi.xssf.usermodel.XSSFWorkbook wb, org.apache.poi.ss.usermodel.Row row, int cellNumber, String cellComment, int rowCount, int columnCount, boolean commentVisible)
    • setDateValue

      public static void setDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, Date date, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • setDoubleValue

      public static void setDoubleValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, Double value, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • setBooleanValue

      public static void setBooleanValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean value, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • setDateValue

      public static void setDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, String dateString, String dateFormat, org.apache.poi.ss.usermodel.CellStyle cellStyle)
    • getStringValue

      public static String getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean mandatory) throws PoiException
      Returns the string value from the given cell. If the value is mandatory but the cell does not contain a value a PoiException is thrown.
      Parameters:
      row - the row to read the value from
      cellNumber - the cellnumber (starting with 0) of the Row to read the content from.
      mandatory - if set to true, a PoiException is thrown, if the specified cell, does not contain any value. Otherwise null is returned if the cell is empty.
      Returns:
      the String value of the specified cell.
      Throws:
      PoiException - if the cell value cannot be read or if the cell is empty and mandatory has been set to true.
    • getStringValue

      public static String getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber) throws PoiException
      Throws:
      PoiException
    • getStringValue

      public static String getStringValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean returnDefaultValue, String defaultValue) throws PoiException
      Throws:
      PoiException
    • getDateValue

      public static LocalDate getDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber) throws PoiException
      Throws:
      PoiException
    • getDateValue

      public static LocalDate getDateValue(org.apache.poi.ss.usermodel.Row row, int cellNumber, boolean returnDefaultValue, LocalDate defaultValue) throws PoiException
      Throws:
      PoiException
    • getBooleanValue

      public static boolean getBooleanValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, boolean defaultValue) throws PoiException
      Throws:
      PoiException
    • getDoubleValue

      public static double getDoubleValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber) throws PoiException
      Throws:
      PoiException
    • getDoubleValue

      public static Double getDoubleValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, Double defaultValue) throws PoiException
      Throws:
      PoiException
    • getIntegerValue

      public static int getIntegerValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber) throws PoiException
      Throws:
      PoiException
    • getIntegerValue

      public static Integer getIntegerValue(org.apache.poi.ss.usermodel.Row currentRow, int cellNumber, boolean returnDefaultValue, Integer defaultValue) throws PoiException
      Throws:
      PoiException
    • replaceProblematicCharacters

      protected static String replaceProblematicCharacters(String sourceValue)
      remove characters which often cause troubles in other applications - e.g. em dash (long dash) is created by Excel automatically
      Parameters:
      sourceValue - the input string to execute the replacement
      Returns:
      sourceValue with replaced characters