Package com.atlan.samples.readers
Class ExcelReader
- java.lang.Object
-
- com.atlan.samples.readers.ExcelReader
-
public class ExcelReader extends java.lang.Object
Utility class for parsing and reading the contents of Excel files, using Apache POI.
-
-
Constructor Summary
Constructors Constructor Description ExcelReader(java.lang.String fileLocation)
Construct a new Excel file reader.ExcelReader(java.lang.String fileLocation, java.lang.String caseSensitiveDelimiter)
Construct a new Excel file reader allowing for case-sensitive column headings.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getRowsFromSheet(int index)
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getRowsFromSheet(int index, int headerRow)
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getRowsFromSheet(java.lang.String name)
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getRowsFromSheet(java.lang.String name, int headerRow)
Retrieve all rows from the specified sheet of the Excel workbook.
-
-
-
Constructor Detail
-
ExcelReader
public ExcelReader(java.lang.String fileLocation) throws java.io.IOException
Construct a new Excel file reader.- Parameters:
fileLocation
- location of the Excel file- Throws:
java.io.IOException
- on any errors accessing or parsing the file
-
ExcelReader
public ExcelReader(java.lang.String fileLocation, java.lang.String caseSensitiveDelimiter) throws java.io.IOException
Construct a new Excel file reader allowing for case-sensitive column headings.- Parameters:
fileLocation
- location of the Excel filecaseSensitiveDelimiter
- delimiter to look for to leave a column heading as case-sensitive- Throws:
java.io.IOException
- on any errors accessing or parsing the file
-
-
Method Detail
-
getRowsFromSheet
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getRowsFromSheet(int index)
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.- Parameters:
index
- the index (0-based) of the worksheet within the workbook- Returns:
- a list of rows, each being a mapping from column name (upper-cased) to its value
-
getRowsFromSheet
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getRowsFromSheet(int index, int headerRow)
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.- Parameters:
index
- the index (0-based) of the worksheet within the workbookheaderRow
- index of the row containing headers (0-based)- Returns:
- a list of rows, each being a mapping from column name (upper-cased) to its value
-
getRowsFromSheet
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getRowsFromSheet(java.lang.String name) throws java.io.IOException
Retrieve all rows from the specified sheet of the Excel workbook, using the very first row (0) as the header row.- Parameters:
name
- of the worksheet from which to retrieve the data- Returns:
- a list of rows, each being a mapping from column name (upper-cased) to its value
- Throws:
java.io.IOException
- if the requested sheet cannot be found in the provided Excel file
-
getRowsFromSheet
public java.util.List<java.util.Map<java.lang.String,java.lang.String>> getRowsFromSheet(java.lang.String name, int headerRow) throws java.io.IOException
Retrieve all rows from the specified sheet of the Excel workbook.- Parameters:
name
- of the worksheet from which to retrieve the dataheaderRow
- index of the row containing headers (0-based)- Returns:
- a list of rows, each being a mapping from column name (upper-cased) to its value
- Throws:
java.io.IOException
- if the requested sheet cannot be found in the provided Excel file
-
-