|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcsv.impl.AbstractTableReader
csv.impl.AbstractStreamTableReader
csv.impl.ExcelReader
public class ExcelReader
Implements Excel reading.
This class reads Excel sheets like a stream, meaning
delivering rows one by one from the current sheet.
* Use this reader if you want to load an Excel file by creating a File
and passing it to the constructor.
Example:
java.io.File f = new java.io.File("excel-test.xls");
ExcelReader in = new ExcelReader(f);
while (in.hasNext()) {
Object columns[] = in.next();
// Do something here
}
in.close();
selectSheet(int),
selectSheet(String)| Constructor Summary | |
|---|---|
ExcelReader()
Default constructor. |
|
ExcelReader(java.io.File file)
Constructor for reading from a file. |
|
ExcelReader(java.io.InputStream in)
Constructor to read from an existing stream. |
|
ExcelReader(java.lang.String file)
Constructor for reading from a file. |
|
ExcelReader(org.apache.poi.ss.usermodel.Workbook workbook)
Constructor to read from an existing workbook. |
|
| Method Summary | |
|---|---|
java.lang.Object |
evaluateCellValue(org.apache.poi.ss.usermodel.Cell cell)
Returns the evaluated cell content. |
org.apache.poi.ss.usermodel.FormulaEvaluator |
getFormulaEvaluator()
Returns a formula evaluator for the current workbook. |
org.apache.poi.ss.usermodel.Row |
getLastExcelRow()
Returns the last delivered row. |
org.apache.poi.ss.usermodel.Sheet |
getSheet()
Returns the current sheet. |
java.lang.Object |
getValue(org.apache.poi.ss.usermodel.Cell cell)
Returns the value of the specified cell. |
java.lang.Object |
getValue(int rownum,
int cellNum)
Returns the value of the specified cell. |
java.lang.Object |
getValue(org.apache.poi.ss.usermodel.Row row,
int cellNum)
Returns the value of the specified cell. |
java.lang.Object[] |
getValues(int rowNum)
Returns the row at the given index. |
java.lang.Object[] |
getValues(org.apache.poi.ss.usermodel.Row row)
Returns the row as Java objects. |
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
Returns the workbook. |
boolean |
hasNext()
Returns whether there is a row to be read in the current sheet. |
java.lang.Object[] |
next()
Returns the next row. |
void |
open()
Opens the stream by retrieving the workbook and selecting the first sheet. |
protected void |
readHeaderRow()
Reads the header row from next line. |
void |
reset()
Resets the reader by resetting the current row index |
protected void |
retrieveNextRow()
Retrieves the next row from the current sheet. |
org.apache.poi.ss.usermodel.Sheet |
selectSheet(int index)
Select the given sheet to be read from. |
org.apache.poi.ss.usermodel.Sheet |
selectSheet(org.apache.poi.ss.usermodel.Sheet sheet)
Select the given sheet to be read from. |
org.apache.poi.ss.usermodel.Sheet |
selectSheet(java.lang.String name)
Select the given sheet to be read from. |
| Methods inherited from class csv.impl.AbstractStreamTableReader |
|---|
close, getInputStream, getReader, remove, setInputStream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ExcelReader()
public ExcelReader(java.io.File file)
throws java.io.FileNotFoundException
file - file to read from
java.io.FileNotFoundException - when file does not existpublic ExcelReader(java.io.InputStream in)
in - input stream to be usedpublic ExcelReader(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - the workbook be used
public ExcelReader(java.lang.String file)
throws java.io.FileNotFoundException
file - file to read from
java.io.FileNotFoundException - when file does not exist| Method Detail |
|---|
public void open()
open in interface TableReaderopen in class AbstractTableReaderAbstractTableReader.open()public org.apache.poi.ss.usermodel.Workbook getWorkbook()
public org.apache.poi.ss.usermodel.Sheet selectSheet(java.lang.String name)
name - name of sheet
public org.apache.poi.ss.usermodel.Sheet selectSheet(org.apache.poi.ss.usermodel.Sheet sheet)
sheet - sheet to be selected
public org.apache.poi.ss.usermodel.Sheet selectSheet(int index)
index - index of sheet
public org.apache.poi.ss.usermodel.Sheet getSheet()
public org.apache.poi.ss.usermodel.Row getLastExcelRow()
next().
next()public void reset()
reset in interface TableReaderreset in class AbstractStreamTableReaderAbstractStreamTableReader.reset(),
AbstractTableReader.getRowCount()public boolean hasNext()
Iterator.hasNext(),
selectSheet(int)public java.lang.Object[] next()
Iterator.next(),
AbstractTableReader.getRowCount()public java.lang.Object[] getValues(int rowNum)
rowNum - row index to read
public java.lang.Object[] getValues(org.apache.poi.ss.usermodel.Row row)
row - row to read
public java.lang.Object getValue(int rownum,
int cellNum)
rownum - row indexcellNum - column index
public java.lang.Object getValue(org.apache.poi.ss.usermodel.Row row,
int cellNum)
row - row objectcellNum - column index
public java.lang.Object getValue(org.apache.poi.ss.usermodel.Cell cell)
cell - cell object
public java.lang.Object evaluateCellValue(org.apache.poi.ss.usermodel.Cell cell)
cell - cell to evaluate
public org.apache.poi.ss.usermodel.FormulaEvaluator getFormulaEvaluator()
protected void readHeaderRow()
readHeaderRow in class AbstractTableReaderAbstractTableReader.readHeaderRow()protected void retrieveNextRow()
hasNext()
and next(). Blank rows are skipped.
|
Copyright © 2008-2011 Ralph Schuster. All Rights Reserved. | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||