public class JRXlsDataSource 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 CSV file.
Constructor and Description |
---|
JRXlsDataSource(java.io.File file)
Creates a data source instance from an XLS file.
|
JRXlsDataSource(java.io.InputStream is)
Creates a data source instance from an XLS data input stream.
|
JRXlsDataSource(java.lang.String location)
Creates a datasource instance that reads XLS data from a given location.
|
JRXlsDataSource(jxl.Workbook workbook)
Creates a data source instance from a workbook.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the reader.
|
java.text.DateFormat |
getDateFormat()
Gets the date format that will be used to parse date fields.
|
java.lang.Object |
getFieldValue(JRField jrField)
Gets the field value for the current position.
|
java.text.NumberFormat |
getNumberFormat()
Gets the number format that will be used to parse numeric fields.
|
void |
moveFirst()
Moves back to the first element in the data source.
|
boolean |
next()
Tries to position the cursor on the next element in the data source.
|
void |
setColumnIndexes(java.lang.Integer[] columnIndexes)
Specifies an array of integers representing the column indexes in the sheet.
|
void |
setColumnNames(java.lang.String[] columnNames)
Specifies an array of strings representing column names matching field names in the report template.
|
void |
setColumnNames(java.lang.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(java.text.DateFormat dateFormat)
Sets the desired date format to be used for parsing date fields.
|
void |
setNumberFormat(java.text.NumberFormat numberFormat)
Sets the desired number format to be used for parsing numeric fields.
|
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, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTimeZone, setTimeZone
public JRXlsDataSource(jxl.Workbook workbook)
workbook
- the workbookpublic JRXlsDataSource(java.io.InputStream is) throws JRException, java.io.IOException
is
- an input stream containing XLS dataJRException
java.io.IOException
public JRXlsDataSource(java.io.File file) throws JRException, java.io.FileNotFoundException, java.io.IOException
file
- a file containing XLS dataJRException
java.io.FileNotFoundException
java.io.IOException
public JRXlsDataSource(java.lang.String location) throws JRException, java.io.IOException
location
- a String representing XLS data sourcejava.io.IOException
JRException
public boolean next() throws JRException
JRDataSource
next
in interface JRDataSource
JRException
- if any error occurs while trying to move to the next elementpublic void moveFirst()
JRRewindableDataSource
moveFirst
in interface JRRewindableDataSource
public java.lang.Object getFieldValue(JRField jrField) throws JRException
JRDataSource
getFieldValue
in interface JRDataSource
JRException
public java.text.DateFormat getDateFormat()
public void setDateFormat(java.text.DateFormat dateFormat)
public java.text.NumberFormat getNumberFormat()
public void setNumberFormat(java.text.NumberFormat numberFormat)
public void setColumnNames(java.lang.String[] columnNames)
public void setColumnNames(java.lang.String[] columnNames, int[] columnIndexes)
public void setColumnIndexes(java.lang.Integer[] columnIndexes)
public void setUseFirstRowAsHeader(boolean useFirstRowAsHeader)
public void close()
© 2001-2010 Jaspersoft Corporation www.jaspersoft.com