Package net.sf.jasperreports.engine.data
Class AbstractXlsDataSource
java.lang.Object
net.sf.jasperreports.engine.data.JRAbstractTextDataSource
net.sf.jasperreports.engine.data.AbstractXlsDataSource
- All Implemented Interfaces:
- JRDataSource,- JRRewindableDataSource
- Direct Known Subclasses:
- AbstractPoiXlsDataSource,- FastExcelDataSource
public abstract class AbstractXlsDataSource
extends JRAbstractTextDataSource
implements JRRewindableDataSource
This data source implementation reads an XLSX or XLS stream.
 
The default naming convention is to name report fields COLUMN_x and map each column with the field found at index x in each row (these indices start with 0). To avoid this situation, users can either specify a collection of column names or set a flag to read the column names from the first row of the XLSX or XLS file.
- Author:
- Sanda Zaharia (shertage@users.sourceforge.net)
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected DateFormatstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected NumberFormatstatic final StringProperty specifying the XLS column index for the dataset field.static final StringProperty specifying the XLS column name for the dataset field.protected Stringprotected booleanFields inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSourceEXCEPTION_MESSAGE_KEY_CANNOT_CONVERT_FIELD_TYPE, EXCEPTION_MESSAGE_KEY_CANNOT_MODIFY_PROPERTIES_AFTER_START, EXCEPTION_MESSAGE_KEY_NODE_NOT_AVAILABLE, EXCEPTION_MESSAGE_KEY_NULL_DOCUMENT, EXCEPTION_MESSAGE_KEY_NULL_SELECT_EXPRESSION, EXCEPTION_MESSAGE_KEY_UNKNOWN_COLUMN_NAME, EXCEPTION_MESSAGE_KEY_UNKNOWN_NUMBER_TYPE
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract voidabstract voidclose()Closes the reader.protected IntegergetColumnIndex(JRField field) Gets the date format that will be used to parse date fields.Gets the number format that will be used to parse numeric fields.voidsetColumnIndexes(Integer[] columnIndexes) Specifies an array of integers representing the column indexes in the sheet.voidsetColumnNames(String[] columnNames) Specifies an array of strings representing column names matching field names in the report template.voidsetColumnNames(String[] columnNames, int[] columnIndexes) Specifies an array of strings representing column names matching field names in the report template and an array of integers representing the column indexes in the sheet.voidsetDateFormat(DateFormat dateFormat) Sets the desired date format to be used for parsing date fields.voidsetNumberFormat(NumberFormat numberFormat) Sets the desired number format to be used for parsing numeric fields.voidsetSheetSelection(String sheetSelection) voidsetUseFirstRowAsHeader(boolean useFirstRowAsHeader) Specifies whether the first row of the XLS file should be considered a table header, containing column names matching field names in the report template.Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSourceconvertNumber, convertStringValue, getConvertBean, getDatePattern, getLocale, getNumberPattern, getTextAttributes, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTextAttributes, setTimeZone, setTimeZoneMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.sf.jasperreports.engine.JRDataSourcegetFieldValue, nextMethods inherited from interface net.sf.jasperreports.engine.JRRewindableDataSourcemoveFirst
- 
Field Details- 
EXCEPTION_MESSAGE_KEY_XLS_COLUMN_NAMES_MISMATCH_COLUMN_INDEXES- See Also:
 
- 
EXCEPTION_MESSAGE_KEY_XLS_FIELD_VALUE_NOT_RETRIEVED- See Also:
 
- 
EXCEPTION_MESSAGE_KEY_XLS_SHEET_INDEX_OUT_OF_RANGE- See Also:
 
- 
EXCEPTION_MESSAGE_KEY_XLS_SHEET_NOT_FOUND- See Also:
 
- 
PROPERTY_FIELD_COLUMN_NAMEProperty specifying the XLS column name for the dataset field.- See Also:
 
- 
PROPERTY_FIELD_COLUMN_INDEXProperty specifying the XLS column index for the dataset field.- See Also:
 
- 
INDEXED_COLUMN_PREFIX- See Also:
 
- 
sheetSelection
- 
dateFormat
- 
numberFormat
- 
columnNames
- 
useFirstRowAsHeaderprotected boolean useFirstRowAsHeader
- 
columnIndexMap
 
- 
- 
Constructor Details- 
AbstractXlsDataSourcepublic AbstractXlsDataSource()
 
- 
- 
Method Details- 
getDateFormatGets the date format that will be used to parse date fields.
- 
setDateFormatSets the desired date format to be used for parsing date fields.
- 
getNumberFormatGets the number format that will be used to parse numeric fields.
- 
setNumberFormatSets the desired number format to be used for parsing numeric fields.
- 
setColumnNamesSpecifies an array of strings representing column names matching field names in the report template.
- 
setColumnNamesSpecifies an array of strings representing column names matching field names in the report template and an array of integers representing the column indexes in the sheet. Both array parameters must be not-null and have the same number of values.
- 
setColumnIndexesSpecifies an array of integers representing the column indexes in the sheet.
- 
setUseFirstRowAsHeaderpublic void setUseFirstRowAsHeader(boolean useFirstRowAsHeader) Specifies whether the first row of the XLS file should be considered a table header, containing column names matching field names in the report template.
- 
closepublic abstract void close()Closes the reader. Users of this data source should close it after usage.
- 
checkReadStartedprotected abstract void checkReadStarted()
- 
getColumnNames
- 
getSheetSelection
- 
setSheetSelection
- 
getColumnIndex- Throws:
- JRException
 
 
-