Class Spreadsheet


  • @ProviderType
    public class Spreadsheet
    extends Object
    Simple abstraction of reading a single spreadsheet of values. Expects a header row of named columns (case-sensitive) If provided, will also filter data rows missing required columns to prevent processing errors.
    • Constructor Detail

      • Spreadsheet

        public Spreadsheet​(boolean convertHeaderNames,
                           String... headerArray)
        Simple constructor used for unit testing purposes
        Parameters:
        convertHeaderNames - If true, header names are converted
        headerArray - List of strings for header columns
      • Spreadsheet

        public Spreadsheet​(boolean convertHeaderNames,
                           List<String> caseInsensitiveHeaders,
                           String... headerArray)
        Simple constructor used for unit testing purposes
        Parameters:
        convertHeaderNames - If true, header names are converted
        caseInsensitiveHeaders - Header names that will be ignored during conversion
        headerArray - List of strings for header columns
      • Spreadsheet

        public Spreadsheet​(boolean convertHeaderNames,
                           InputStream file,
                           String... required)
      • Spreadsheet

        public Spreadsheet​(boolean convertHeaderNames,
                           org.apache.sling.api.request.RequestParameter file,
                           String... required)
                    throws IOException
        Throws:
        IOException
      • Spreadsheet

        public Spreadsheet​(org.apache.sling.api.request.RequestParameter file,
                           String... required)
                    throws IOException
        Throws:
        IOException
    • Method Detail

      • buildSpreadsheet

        public Spreadsheet buildSpreadsheet()
                                     throws IOException
        Parse out the input file synchronously for easier unit test validation. This overload will implicitly use the default JVM locale for numeric and date/time conversions.
        Returns:
        List of files that will be imported, including any renditions
        Throws:
        IOException - if the file couldn't be read
      • buildSpreadsheet

        public Spreadsheet buildSpreadsheet​(Locale locale)
                                     throws IOException
        Parse out the input file synchronously for easier unit test validation
        Parameters:
        locale - The locale to be used for numeric and date/time conversions.
        Returns:
        List of files that will be imported, including any renditions
        Throws:
        IOException - if the file couldn't be read
      • getFileName

        public String getFileName()
        Returns:
        the fileName
      • getRowCount

        public int getRowCount()
        Returns:
        the rowCount
      • getHeaderRow

        public List<String> getHeaderRow()
        Returns:
        the headerRow
      • getRequiredColumns

        public List<String> getRequiredColumns()
        Returns:
        the requiredColumns
      • convertHeaderName

        public String convertHeaderName​(String str)