Class ExcelUtil


  • public class ExcelUtil
    extends Object
    Utilities for dealign with Microsoft Excel spreadsheets as implemented in commons-poi.
    Author:
    lfrench
    • Constructor Detail

      • ExcelUtil

        public ExcelUtil()
    • Method Detail

      • getSheetFromFile

        public static org.apache.poi.hssf.usermodel.HSSFSheet getSheetFromFile​(String filename,
                                                                               String sheetName)
                                                                        throws IOException
        Parameters:
        filename -
        sheetName -
        Returns:
        Throws:
        IOException
      • getValue

        public static String getValue​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                      int row,
                                      int col)
        Parameters:
        sheet -
        row -
        col -
        Returns:
      • grabColumnValues

        public static Set<String> grabColumnValues​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                                   int column,
                                                   boolean header,
                                                   boolean clean)
        Parameters:
        sheet -
        column -
        header -
        clean -
        Returns:
      • grabColumnValues

        public static Set<String> grabColumnValues​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                                   int column,
                                                   boolean header,
                                                   boolean clean,
                                                   SpreadSheetFilter f)
        Gets all the strings from a column, possibly excluding header and possibly trimming and lowercasing
        Parameters:
        sheet -
        column -
        header - true if it has a header
        clean - if true it will trim and lowercase the strings
        Returns:
      • grabColumnValuesList

        public static List<String> grabColumnValuesList​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                                        int column,
                                                        boolean header,
                                                        boolean clean)
        Parameters:
        sheet -
        column -
        header -
        clean -
        Returns:
      • grabColumnValuesList

        public static List<String> grabColumnValuesList​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                                        int column,
                                                        boolean header,
                                                        boolean clean,
                                                        SpreadSheetFilter f)
        Parameters:
        sheet -
        column - the index of the column to get
        header - if there is a header row to be skipped
        clean - lower case
        f -
        Returns:
      • main

        public static void main​(String[] args)
      • setFormula

        public static void setFormula​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                      int row,
                                      int col,
                                      String value)
        Parameters:
        sheet -
        row -
        col -
        value -
      • setValue

        public static void setValue​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                    int row,
                                    int col,
                                    double value)
        Parameters:
        sheet -
        row -
        col -
        value -
      • setValue

        public static void setValue​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                    int row,
                                    int col,
                                    int value)
        Parameters:
        sheet -
        row -
        col -
        value -
      • setValue

        public static void setValue​(org.apache.poi.hssf.usermodel.HSSFSheet sheet,
                                    int row,
                                    int col,
                                    String value)
        Parameters:
        sheet -
        row -
        col -
        value -