Package com.adobe.acs.commons.data
Class Spreadsheet
java.lang.Object
com.adobe.acs.commons.data.Spreadsheet
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSpreadsheet(boolean convertHeaderNames, InputStream file, String... required) Spreadsheet(boolean convertHeaderNames, String... headerArray) Simple constructor used for unit testing purposesSpreadsheet(boolean convertHeaderNames, List<String> caseInsensitiveHeaders, String... headerArray) Simple constructor used for unit testing purposesSpreadsheet(boolean convertHeaderNames, org.apache.sling.api.request.RequestParameter file, String... required) Spreadsheet(InputStream file, String... required) Spreadsheet(org.apache.sling.api.request.RequestParameter file, String... required) Spreadsheet(org.apache.sling.api.request.RequestParameter file, List<String> caseInsensitiveHeaders, String... required) -
Method Summary
Modifier and TypeMethodDescriptionvoidappendData(List<Map<String, CompositeVariant>> dataRows) Append data to the sheet.Parse out the input file synchronously for easier unit test validation.buildSpreadsheet(Locale locale) Parse out the input file synchronously for easier unit test validationconvertHeaderName(String str) intgetRowNum(Map<String, CompositeVariant> row) voidSort the data rows by the provided column name
-
Field Details
-
DEFAULT_DELIMITER
- See Also:
-
ROW_NUMBER
- See Also:
-
-
Constructor Details
-
Spreadsheet
Simple constructor used for unit testing purposes- Parameters:
convertHeaderNames- If true, header names are convertedheaderArray- 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 convertedcaseInsensitiveHeaders- Header names that will be ignored during conversionheaderArray- List of strings for header columns
-
Spreadsheet
-
Spreadsheet
public Spreadsheet(boolean convertHeaderNames, org.apache.sling.api.request.RequestParameter file, String... required) throws IOException - Throws:
IOException
-
Spreadsheet
-
Spreadsheet
public Spreadsheet(org.apache.sling.api.request.RequestParameter file, String... required) throws IOException - Throws:
IOException
-
Spreadsheet
public Spreadsheet(org.apache.sling.api.request.RequestParameter file, List<String> caseInsensitiveHeaders, String... required) throws IOException - Throws:
IOException
-
-
Method Details
-
buildSpreadsheet
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
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
- Returns:
- the fileName
-
getRowCount
public int getRowCount()- Returns:
- the rowCount
-
getHeaderRow
- Returns:
- the headerRow
-
getDataRowsAsCompositeVariants
- Returns:
- the dataRows
-
sortRows
Sort the data rows by the provided column name -
appendData
Append data to the sheet.- Parameters:
dataRows- the data to append
-
getRowNum
-
getRequiredColumns
- Returns:
- the requiredColumns
-
convertHeaderName
-