net.sf.jasperreports.engine.data

## Class AbstractXlsDataSource

- java.lang.Object
- - net.sf.jasperreports.engine.data.JRAbstractTextDataSource
  - - net.sf.jasperreports.engine.data.AbstractXlsDataSource

- All Implemented Interfaces:
    JRDataSource, JRRewindableDataSource
  Direct Known Subclasses:
    AbstractPoiXlsDataSource, JRXlsDataSource

      public abstract class AbstractXlsDataSource
      extends JRAbstractTextDataSource
      implements JRRewindableDataSource

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

  Version:
    $Id: ExcelDataSource.java 6968 2014-03-12 08:58:07Z shertage $
  Author:
    sanda zaharia (shertage@users.sourceforge.net)

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.util.Map<java.lang.String,java.lang.Integer>` | `columnNames`
    `protected java.text.DateFormat` | `dateFormat`
    `protected java.text.NumberFormat` | `numberFormat`
    `protected java.lang.String` | `sheetSelection`
    `protected boolean` | `useFirstRowAsHeader`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractXlsDataSource()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract void` | `checkReadStarted()`
    `abstract 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.text.NumberFormat` | `getNumberFormat()` Gets the number format that will be used to parse numeric fields.
    `java.lang.String` | `getSheetSelection()`
    `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` | `setSheetSelection(java.lang.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.

    - ### 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`

    - ### Methods inherited from interface net.sf.jasperreports.engine.JRRewindableDataSource

      `moveFirst`

    - ### Methods inherited from interface net.sf.jasperreports.engine.JRDataSource

      `getFieldValue, next`

- - ### Field Detail

    - #### sheetSelection

          protected java.lang.String sheetSelection

    - #### dateFormat

          protected java.text.DateFormat dateFormat

    - #### numberFormat

          protected java.text.NumberFormat numberFormat

    - #### columnNames

          protected java.util.Map<java.lang.String,java.lang.Integer> columnNames

    - #### useFirstRowAsHeader

          protected boolean useFirstRowAsHeader

  - ### Constructor Detail

    - #### AbstractXlsDataSource

          public AbstractXlsDataSource()

  - ### Method Detail

    - #### 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 abstract void close()

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

    - #### checkReadStarted

          protected abstract void checkReadStarted()

    - #### getColumnNames

          public java.util.Map<java.lang.String,java.lang.Integer> getColumnNames()

    - #### getSheetSelection

          public java.lang.String getSheetSelection()

    - #### setSheetSelection

          public void setSheetSelection(java.lang.String sheetSelection)

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com