public abstract class AbstractXlsDataSource extends JRAbstractTextDataSource implements JRRewindableDataSource
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.
Modifier and Type | Field and Description |
---|---|
protected Map<String,Integer> |
columnNames |
protected DateFormat |
dateFormat |
static String |
EXCEPTION_MESSAGE_KEY_XLS_COLUMN_NAMES_MISMATCH_COLUMN_INDEXES |
static String |
EXCEPTION_MESSAGE_KEY_XLS_FIELD_VALUE_NOT_RETRIEVED |
static String |
EXCEPTION_MESSAGE_KEY_XLS_SHEET_INDEX_OUT_OF_RANGE |
static String |
EXCEPTION_MESSAGE_KEY_XLS_SHEET_NOT_FOUND |
protected NumberFormat |
numberFormat |
protected String |
sheetSelection |
protected boolean |
useFirstRowAsHeader |
EXCEPTION_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 and Description |
---|
AbstractXlsDataSource() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
checkReadStarted() |
abstract void |
close()
Closes the reader.
|
Map<String,Integer> |
getColumnNames() |
DateFormat |
getDateFormat()
Gets the date format that will be used to parse date fields.
|
NumberFormat |
getNumberFormat()
Gets the number format that will be used to parse numeric fields.
|
String |
getSheetSelection() |
void |
setColumnIndexes(Integer[] columnIndexes)
Specifies an array of integers representing the column indexes in the sheet.
|
void |
setColumnNames(String[] columnNames)
Specifies an array of strings representing column names matching field names in the report template.
|
void |
setColumnNames(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.
|
void |
setDateFormat(DateFormat dateFormat)
Sets the desired date format to be used for parsing date fields.
|
void |
setNumberFormat(NumberFormat numberFormat)
Sets the desired number format to be used for parsing numeric fields.
|
void |
setSheetSelection(String sheetSelection) |
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.
|
convertNumber, convertStringValue, getConvertBean, getDatePattern, getFormattedDate, getFormattedNumber, getLocale, getNumberPattern, getTextAttributes, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTextAttributes, setTimeZone, setTimeZone
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
moveFirst
getFieldValue, next
public static final String EXCEPTION_MESSAGE_KEY_XLS_COLUMN_NAMES_MISMATCH_COLUMN_INDEXES
public static final String EXCEPTION_MESSAGE_KEY_XLS_FIELD_VALUE_NOT_RETRIEVED
public static final String EXCEPTION_MESSAGE_KEY_XLS_SHEET_INDEX_OUT_OF_RANGE
public static final String EXCEPTION_MESSAGE_KEY_XLS_SHEET_NOT_FOUND
protected String sheetSelection
protected DateFormat dateFormat
protected NumberFormat numberFormat
protected boolean useFirstRowAsHeader
public DateFormat getDateFormat()
public void setDateFormat(DateFormat dateFormat)
public NumberFormat getNumberFormat()
public void setNumberFormat(NumberFormat numberFormat)
public void setColumnNames(String[] columnNames)
public void setColumnNames(String[] columnNames, int[] columnIndexes)
public void setColumnIndexes(Integer[] columnIndexes)
public void setUseFirstRowAsHeader(boolean useFirstRowAsHeader)
public abstract void close()
protected abstract void checkReadStarted()
public String getSheetSelection()
public void setSheetSelection(String sheetSelection)
Copyright © 2016. All rights reserved.