io.github.relbraun.poi.ss.reader.SpreadsheetReader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of poi-object-mapper Show documentation
Show all versions of poi-object-mapper Show documentation
Objects mapper for Office formats - Excel files, Spreadsheets, etc.
The newest version!
package io.github.relbraun.poi.ss.reader;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import io.github.relbraun.poi.SpreadsheetReadException;
import io.github.relbraun.poi.ss.handler.RowListener;
/**
* An Abstract representation of a Spreadsheet Reader. Any reader implementation (HSSF or XSSF) is
* expected to implement and provide the below APIs.
*
*/
public interface SpreadsheetReader {
// Read with Custom RowListener
/**
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
* the available sheets of the file and creates the objects of the passed type.
*
*
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
* Suited for reading Large files in restricted memory environments.
*
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param file {@link File} object of the spreadsheet file
* @param listener Custom {@link RowListener} implementation for row data callbacks.
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
void read(Class beanClz, File file, RowListener listener) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
* the available sheets of the file and creates the objects of the passed type.
*
*
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
* Suited for reading Large files in restricted memory environments.
*
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param is {@link InputStream} of the spreadsheet file
* @param listener Custom {@link RowListener} implementation for row data callbacks.
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
void read(Class beanClz, InputStream is, RowListener listener) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
* (sheet numbers are indexed from 0) will be read.
*
*
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
* Suited for reading Large files in restricted memory environments.
*
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param file {@link File} object of the spreadsheet file
* @param sheetNo index of the Sheet to be read (index starts from 0)
* @param listener Custom {@link RowListener} implementation for row data callbacks.
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
void read(Class beanClz, File file, int sheetNo, RowListener listener) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
* (sheet numbers are indexed from 0) will be read.
*
*
* The {@link RowListener} implementation callback gets triggered after reading each Row. Best
* Suited for reading Large files in restricted memory environments.
*
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param is {@link InputStream} of the spreadsheet file
* @param sheetNo index of the Sheet to be read (index starts from 0)
* @param listener Custom {@link RowListener} implementation for row data callbacks.
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
void read(Class beanClz, InputStream is, int sheetNo, RowListener listener)
throws SpreadsheetReadException;
// Read with default RowListener
/**
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
* the available sheets of the file and creates the objects of the passed type.
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param file {@link File} object of the spreadsheet file
*
* @return a {@link List} of objects of the parameterized type
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
List read(Class beanClz, File file) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. This method will attempt to read all
* the available sheets of the file and creates the objects of the passed type.
*
* @param The Parameterized bean Class.
* @param beanClz The Class type to deserialize the rows data
* @param is {@link InputStream} of the spreadsheet file
*
* @return a {@link List} of objects of the parameterized type
*
* @throws SpreadsheetReadException an exception is thrown in cases where the file data is not
* readable or row data to bean mapping failed.
*/
List read(Class beanClz, InputStream is) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
* (sheet numbers are indexed from 0) will be read.
*
* @param The Parameterized bean Class.
* @param beanClz beanClz The Class type to deserialize the rows data
* @param file file {@link File} object of the spreadsheet file
* @param sheetNo index of the Sheet to be read (index starts from 0)
*
* @return a {@link List} of objects of the parameterized type
*
* @throws SpreadsheetReadException SpreadsheetReadException an exception is thrown in cases
* where the file data is not readable or row data to bean mapping failed.
*/
List read(Class beanClz, File file, int sheetNo) throws SpreadsheetReadException;
/**
* Reads the spreadsheet file to beans of the given type. Note that only the requested sheet
* (sheet numbers are indexed from 0) will be read.
*
* @param The Parameterized bean Class.
* @param beanClz beanClz The Class type to deserialize the rows data
* @param is {@link InputStream} of the spreadsheet file
* @param sheetNo index of the Sheet to be read (index starts from 0)
*
* @return a {@link List} of objects of the parameterized type
*
* @throws SpreadsheetReadException SpreadsheetReadException an exception is thrown in cases
* where the file data is not readable or row data to bean mapping failed.
*/
List read(Class beanClz, InputStream is, int sheetNo) throws SpreadsheetReadException;
}