dsql.value
Class ExcelDataValue

java.lang.Object
  extended bydsql.DMExecuted
      extended bydsql.value.Value
          extended bydsql.value.NonScalarValue
              extended bydsql.value.TableResult
                  extended bydsql.value.AbstractResults
                      extended bydsql.value.ExcelDataValue
All Implemented Interfaces:
ColumnHolder, Cursor, DataValue, RecordHolder

public class ExcelDataValue
extends AbstractResults
implements DataValue

Read an excel file using the POI library (http://jakarta.apache.org/poi/). The results is the set of all sheets, each sheet correspond to a table


Field Summary
 
Fields inherited from class dsql.value.TableResult
primaryKeys
 
Constructor Summary
ExcelDataValue()
           
 
Method Summary
 void addCurrentResultMeta(ConstructedResults r)
           
 void allreset()
           
protected  java.lang.String convertDateFormatString(java.lang.String formatStr)
           
 int currentRecord()
           
 void deleteRecord()
           
protected  int findColumn(java.lang.String label)
           
protected  boolean first100AreInteger(short col)
          there is no way to know if numeric cells with generic format are reals or integers... this method returns true if the first 100 rows do not include reals (or dates)
protected  int getCellType(org.apache.poi.hssf.usermodel.HSSFCell cell)
           
 java.lang.Object getColumn(int i)
           
 java.lang.Object getColumn(java.lang.String s)
           
 int getColumnCount()
           
 int getColumnDisplaySize(int i)
           
 java.lang.String getColumnLabel(int i)
           
 java.lang.String getColumnString(int i)
          First column is 1
 java.lang.String getColumnString(java.lang.String s)
           
 ConstructedResults getMeta(boolean all)
           
 int getRecordCount()
          this function should be called with care as it can be computationaly expensive for SQL Cursors!
protected  java.lang.String[] getSheetFormats()
           
protected  java.lang.String[] getSheetInternalFormats()
           
protected  java.lang.String[] getSheetLabels()
          find labels from first non-empty row, null if not found side-effect: set firstRowIndex
protected  int[] getSheetTypes()
          find types from first non-empty row, null if not found must be called after getSheetLabels() side-effect: set firstRowIndex
protected  java.lang.String getStringCellValue(short i)
           
 void gotoRecord(int pos)
          first record is 1
 void gotoSheet(int index)
           
 boolean hasResult()
           
 void insert(ColumnHolder rec)
           
 boolean nextRecord()
           
 boolean nextResult()
           
 java.lang.String[] readCurrentRecord()
           
 void reset()
           
 void setContents(ASTXMLElement ele)
          set contents from XML
 void setContents(java.lang.String _fileName, ASTXMLElement ele)
          set contents from file
 java.lang.String toString()
           
 void update(ColumnHolder rec)
           
 
Methods inherited from class dsql.value.AbstractResults
getMeta, print
 
Methods inherited from class dsql.value.TableResult
equalsRecord, getBoolean, getField, getPrimaryKeys, getRecord, getRecord, getString, getTableName, printRecord, setPrimaryKeys, setPrimaryKeys, setRecord
 
Methods inherited from class dsql.value.NonScalarValue
getFields, isScalar, setField
 
Methods inherited from class dsql.value.Value
getFloat, getInt, getObject, getObjectClass, getRecordHolder, getType, getValue, getValue
 
Methods inherited from class dsql.DMExecuted
getCaller, setCaller
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ExcelDataValue

public ExcelDataValue()
Method Detail

toString

public java.lang.String toString()

getMeta

public ConstructedResults getMeta(boolean all)
                           throws ExecuteException
Specified by:
getMeta in class AbstractResults
Parameters:
all - if true, iterates through all results
Throws:
ExecuteException

addCurrentResultMeta

public void addCurrentResultMeta(ConstructedResults r)
                          throws ExecuteException
Specified by:
addCurrentResultMeta in class AbstractResults
Throws:
ExecuteException

setContents

public void setContents(ASTXMLElement ele)
                 throws ExecuteException
Description copied from interface: DataValue
set contents from XML

Specified by:
setContents in interface DataValue
Throws:
ExecuteException

setContents

public void setContents(java.lang.String _fileName,
                        ASTXMLElement ele)
                 throws ExecuteException
Description copied from interface: DataValue
set contents from file

Specified by:
setContents in interface DataValue
Throws:
ExecuteException

allreset

public void allreset()
              throws ExecuteException
Specified by:
allreset in class AbstractResults
Throws:
ExecuteException

hasResult

public boolean hasResult()
Specified by:
hasResult in class AbstractResults

nextResult

public boolean nextResult()
                   throws ExecuteException
Specified by:
nextResult in class AbstractResults
Throws:
ExecuteException

reset

public void reset()
Specified by:
reset in interface Cursor

readCurrentRecord

public java.lang.String[] readCurrentRecord()
                                     throws ExecuteException
Specified by:
readCurrentRecord in class TableResult
Throws:
ExecuteException

getRecordCount

public int getRecordCount()
Description copied from interface: RecordHolder
this function should be called with care as it can be computationaly expensive for SQL Cursors!

Specified by:
getRecordCount in interface RecordHolder
Returns:
number of records

nextRecord

public boolean nextRecord()
Specified by:
nextRecord in interface Cursor

gotoRecord

public void gotoRecord(int pos)
first record is 1

Specified by:
gotoRecord in interface Cursor
Parameters:
pos - is the record position: 1 is the first record, 0 is the record before first, -1 is after the last record

currentRecord

public int currentRecord()
Specified by:
currentRecord in interface Cursor

getColumnString

public java.lang.String getColumnString(int i)
                                 throws ExecuteException
First column is 1

Specified by:
getColumnString in interface ColumnHolder
Throws:
ExecuteException

getColumn

public java.lang.Object getColumn(int i)
                           throws ExecuteException
Specified by:
getColumn in interface ColumnHolder
Parameters:
i - column number (first column is 1)
Returns:
column value; usually a String, but can also be a complex object, such as XmlDataValue.
Throws:
ExecuteException

getColumnString

public java.lang.String getColumnString(java.lang.String s)
                                 throws ExecuteException
Specified by:
getColumnString in interface ColumnHolder
Throws:
ExecuteException

getColumn

public java.lang.Object getColumn(java.lang.String s)
                           throws ExecuteException
Specified by:
getColumn in interface ColumnHolder
Parameters:
s - column name
Returns:
column value; usually a String, but can also be a complex object, such as XmlDataValue.
Throws:
ExecuteException

getColumnCount

public int getColumnCount()
                   throws ExecuteException
Specified by:
getColumnCount in interface ColumnHolder
Throws:
ExecuteException

getColumnLabel

public java.lang.String getColumnLabel(int i)
Specified by:
getColumnLabel in interface ColumnHolder

getColumnDisplaySize

public int getColumnDisplaySize(int i)
                         throws ExecuteException
Specified by:
getColumnDisplaySize in interface ColumnHolder
Overrides:
getColumnDisplaySize in class TableResult
Throws:
ExecuteException

gotoSheet

public void gotoSheet(int index)
               throws ExecuteException
Throws:
ExecuteException

insert

public void insert(ColumnHolder rec)
            throws ExecuteException
Specified by:
insert in class TableResult
Throws:
ExecuteException

deleteRecord

public void deleteRecord()
                  throws ExecuteException
Specified by:
deleteRecord in class TableResult
Throws:
ExecuteException

update

public void update(ColumnHolder rec)
            throws ExecuteException
Specified by:
update in class TableResult
Throws:
ExecuteException

findColumn

protected int findColumn(java.lang.String label)
                  throws ExecuteException
Specified by:
findColumn in class TableResult
Throws:
ExecuteException

getStringCellValue

protected java.lang.String getStringCellValue(short i)

getCellType

protected int getCellType(org.apache.poi.hssf.usermodel.HSSFCell cell)

convertDateFormatString

protected java.lang.String convertDateFormatString(java.lang.String formatStr)

getSheetLabels

protected java.lang.String[] getSheetLabels()
                                     throws ExecuteException
find labels from first non-empty row, null if not found side-effect: set firstRowIndex

Throws:
ExecuteException

getSheetTypes

protected int[] getSheetTypes()
                       throws ExecuteException
find types from first non-empty row, null if not found must be called after getSheetLabels() side-effect: set firstRowIndex

Throws:
ExecuteException

getSheetFormats

protected java.lang.String[] getSheetFormats()
                                      throws ExecuteException
Throws:
ExecuteException

getSheetInternalFormats

protected java.lang.String[] getSheetInternalFormats()
                                              throws ExecuteException
Throws:
ExecuteException

first100AreInteger

protected boolean first100AreInteger(short col)
there is no way to know if numeric cells with generic format are reals or integers... this method returns true if the first 100 rows do not include reals (or dates)