Class ExcelSource

  • All Implemented Interfaces:
    com.d3x.morpheus.frame.DataFrameSource<java.lang.Integer,​java.lang.String,​ExcelSource.Options>

    public class ExcelSource
    extends java.lang.Object
    implements com.d3x.morpheus.frame.DataFrameSource<java.lang.Integer,​java.lang.String,​ExcelSource.Options>
    A component used to initialize a DataFrame from the contents of an Excel sheet
    Author:
    Xavier Witdouck
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ExcelSource.Coordinate
      Defines a zero-based row and column coordinate in an Excel sheet
      static class  ExcelSource.Options
      The options for this source
    • Constructor Summary

      Constructors 
      Constructor Description
      ExcelSource()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.util.List<com.d3x.morpheus.array.ArrayBuilder<java.lang.Object>> createValues​(int rowCount, int colCount)
      Returns a list of column array builders to capture data from sheet
      private java.lang.Object getCellValue​(org.apache.poi.ss.usermodel.Cell cell, org.apache.poi.ss.usermodel.FormulaEvaluator evaluator)
      Returns a typed value from the cell specified
      private com.d3x.morpheus.array.Array<java.lang.String> getHeader​(org.apache.poi.ss.usermodel.Sheet sheet, ExcelSource.Options options)
      Returns the header array based extracted from the sheet
      static com.d3x.morpheus.frame.DataFrame<java.lang.Integer,​java.lang.String> load​(java.util.function.Consumer<ExcelSource.Options> consumer)  
      com.d3x.morpheus.frame.DataFrame<java.lang.Integer,​java.lang.String> read​(java.util.function.Consumer<ExcelSource.Options> consumer)
      Returns a DataFrames loaded from an Excel sheet according to configured options
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface com.d3x.morpheus.frame.DataFrameSource

        initOptions
    • Constructor Detail

      • ExcelSource

        public ExcelSource()
    • Method Detail

      • load

        public static com.d3x.morpheus.frame.DataFrame<java.lang.Integer,​java.lang.String> load​(java.util.function.Consumer<ExcelSource.Options> consumer)
      • read

        public com.d3x.morpheus.frame.DataFrame<java.lang.Integer,​java.lang.String> read​(java.util.function.Consumer<ExcelSource.Options> consumer)
        Returns a DataFrames loaded from an Excel sheet according to configured options
        Specified by:
        read in interface com.d3x.morpheus.frame.DataFrameSource<java.lang.Integer,​java.lang.String,​ExcelSource.Options>
        Parameters:
        consumer - the consumer to configure options
        Returns:
        the resulting DataFrame
      • getHeader

        private com.d3x.morpheus.array.Array<java.lang.String> getHeader​(org.apache.poi.ss.usermodel.Sheet sheet,
                                                                         ExcelSource.Options options)
        Returns the header array based extracted from the sheet
        Parameters:
        sheet - the sheet reference
        options - the options
        Returns:
        the array of header values
      • createValues

        private java.util.List<com.d3x.morpheus.array.ArrayBuilder<java.lang.Object>> createValues​(int rowCount,
                                                                                                   int colCount)
        Returns a list of column array builders to capture data from sheet
        Parameters:
        rowCount - the initial row count for builder
        colCount - the column count for DataFrame
        Returns:
        the list of array builders
      • getCellValue

        private java.lang.Object getCellValue​(org.apache.poi.ss.usermodel.Cell cell,
                                              org.apache.poi.ss.usermodel.FormulaEvaluator evaluator)
        Returns a typed value from the cell specified
        Parameters:
        cell - the cell reference
        evaluator - the formula evaluator
        Returns:
        the cell value