Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.jasperreports.engine.data
Class JRXlsDataSource

    java.lang.Object
      net.sf.jasperreports.engine.data.JRXlsDataSource

All Implemented Interfaces:
  JRDataSource, JRRewindableDataSource

    public class JRXlsDataSource

extends java.lang.Object
implements JRRewindableDataSource

This data source implementation reads an 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 CSV file.

Version:
  $Id: JRCsvDataSource.java 3033 2009-08-27 11:46:22Z teodord $
Author:
  Teodor Danciu (teodord@users.sourceforge.net)

Constructor Summary
`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(jxl.Workbook workbook)` Creates a data source instance from a workbook.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JRXlsDataSource

    public JRXlsDataSource(jxl.Workbook workbook)

  Creates a data source instance from a workbook.

  Parameters:
    `workbook` - the workbook

### JRXlsDataSource

    public JRXlsDataSource(java.io.InputStream is)
                    throws JRException,
                           java.io.IOException

  Creates a data source instance from an XLS data input stream.

  Parameters:
    `is` - an input stream containing XLS data
  Throws:
    `JRException`
    `java.io.IOException`

### JRXlsDataSource

    public JRXlsDataSource(java.io.File file)
                    throws JRException,
                           java.io.FileNotFoundException,
                           java.io.IOException

  Creates a data source instance from an XLS file.

  Parameters:
    `file` - a file containing XLS data
  Throws:
    `JRException`
    `java.io.FileNotFoundException`
    `java.io.IOException`

Method Detail

### next

    public boolean next()
                 throws JRException

  Description copied from interface: `JRDataSource`
  Tries to position the cursor on the next element in the data source.

  Specified by:
    `next` in interface `JRDataSource`
  Returns:
    true if there is a next record, false otherwise
  Throws:
    `JRException` - if any error occurs while trying to move to the next element

### moveFirst

    public void moveFirst()

  Description copied from interface: `JRRewindableDataSource`
  Moves back to the first element in the data source.

  Specified by:
    `moveFirst` in interface `JRRewindableDataSource`

### getFieldValue

    public java.lang.Object getFieldValue(JRField jrField)
                                   throws JRException

  Description copied from interface: `JRDataSource`
  Gets the field value for the current position.

  Specified by:
    `getFieldValue` in interface `JRDataSource`
  Returns:
    an object containing the field value. The object type must be the field object type.
  Throws:
    `JRException`

### getDateFormat

    public java.text.DateFormat getDateFormat()

  Gets the date format that will be used to parse date fields.

### setDateFormat

    public void setDateFormat(java.text.DateFormat dateFormat)

  Sets the desired date format to be used for parsing date fields.

### getNumberFormat

    public java.text.NumberFormat getNumberFormat()

  Gets the number format that will be used to parse numeric fields.

### setNumberFormat

    public void setNumberFormat(java.text.NumberFormat numberFormat)

  Sets the desired number format to be used for parsing numeric fields.

### setColumnNames

    public void setColumnNames(java.lang.String[] columnNames)

  Specifies an array of strings representing column names matching field names in the report template.

### setColumnNames

    public 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. Both array parameters must be not-null and have the same number of values.

### setColumnIndexes

    public void setColumnIndexes(java.lang.Integer[] columnIndexes)

  Specifies an array of integers representing the column indexes in the sheet.

### setUseFirstRowAsHeader

    public 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.

### close

    public void close()

  Closes the reader. Users of this data source should close it after usage.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com