|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jasperreports.engine.data.JRAbstractTextDataSource net.sf.jasperreports.engine.data.JRXlsxDataSource
public class JRXlsxDataSource
This data source implementation reads an XLSX 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 CSV file.
Constructor Summary | |
---|---|
JRXlsxDataSource(java.io.File file)
Creates a data source instance from an XLSX file. |
|
JRXlsxDataSource(java.io.InputStream is)
Creates a data source instance from an XLSX data input stream. |
|
JRXlsxDataSource(JasperReportsContext jasperReportsContext,
java.lang.String location)
Creates a datasource instance that reads XLSX data from a given location. |
|
JRXlsxDataSource(java.lang.String location)
|
|
JRXlsxDataSource(org.apache.poi.ss.usermodel.Workbook workbook)
Creates a data source instance from a workbook. |
Method Summary | |
---|---|
void |
close()
Closes the reader. |
java.util.Map<java.lang.String,java.lang.Integer> |
getColumnNames()
|
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. |
Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractTextDataSource |
---|
convertNumber, convertStringValue, getConvertBean, getDatePattern, getFormattedDate, getFormattedNumber, getLocale, getNumberPattern, getTimeZone, setDatePattern, setLocale, setLocale, setNumberPattern, setTextAttributes, setTimeZone, setTimeZone |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JRXlsxDataSource(org.apache.poi.ss.usermodel.Workbook workbook)
workbook
- the workbookpublic JRXlsxDataSource(java.io.InputStream is) throws JRException, java.io.IOException
is
- an input stream containing XLSX data
JRException
java.io.IOException
public JRXlsxDataSource(java.io.File file) throws JRException, java.io.FileNotFoundException, java.io.IOException
file
- a file containing XLSX data
JRException
java.io.FileNotFoundException
java.io.IOException
public JRXlsxDataSource(JasperReportsContext jasperReportsContext, java.lang.String location) throws JRException, java.io.IOException
jasperReportsContext
- the JasperReportsContextlocation
- a String representing XLSX data source
java.io.IOException
JRException
public JRXlsxDataSource(java.lang.String location) throws JRException, java.io.IOException
JRException
java.io.IOException
JRXlsxDataSource(JasperReportsContext, String)
Method Detail |
---|
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()
public java.util.Map<java.lang.String,java.lang.Integer> getColumnNames()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |