public class JRXlsxDataSource 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 |
|---|
JRXlsxDataSource(File file)
Creates a data source instance from an XLSX file.
|
JRXlsxDataSource(InputStream is)
Creates a data source instance from an XLSX data input stream.
|
JRXlsxDataSource(JasperReportsContext jasperReportsContext,
String location)
Creates a datasource instance that reads XLSX data from a given location.
|
JRXlsxDataSource(String location) |
JRXlsxDataSource(org.apache.poi.ss.usermodel.Workbook workbook)
Creates a data source instance from a workbook.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the reader.
|
Map<String,Integer> |
getColumnNames() |
DateFormat |
getDateFormat()
Gets the date format that will be used to parse date fields.
|
Object |
getFieldValue(JRField jrField)
Gets the field value for the current position.
|
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(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 |
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, setTimeZonepublic JRXlsxDataSource(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - the workbookpublic JRXlsxDataSource(InputStream is) throws JRException, IOException
is - an input stream containing XLSX dataJRExceptionIOExceptionpublic JRXlsxDataSource(File file) throws JRException, FileNotFoundException, IOException
file - a file containing XLSX dataJRExceptionFileNotFoundExceptionIOExceptionpublic JRXlsxDataSource(JasperReportsContext jasperReportsContext, String location) throws JRException, IOException
jasperReportsContext - the JasperReportsContextlocation - a String representing XLSX data sourceIOExceptionJRExceptionpublic JRXlsxDataSource(String location) throws JRException, IOException
JRExceptionIOExceptionJRXlsxDataSource(JasperReportsContext, String)public boolean next()
throws JRException
JRDataSourcenext in interface JRDataSourceJRException - if any error occurs while trying to move to the next elementpublic void moveFirst()
JRRewindableDataSourcemoveFirst in interface JRRewindableDataSourcepublic Object getFieldValue(JRField jrField) throws JRException
JRDataSourcegetFieldValue in interface JRDataSourceJRExceptionpublic 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 void close()
Copyright © 2012. All Rights Reserved.