Elexis API documentation
Version 2.1.6 as of December 11 2011

ch.elexis.importers
Class ExcelWrapper

java.lang.Object
  extended by ch.elexis.importers.ExcelWrapper

public class ExcelWrapper
extends java.lang.Object

A Class that wraps a Microsoft(tm) Excel(tm) Spreadsheet using Apache's HSSF (Horrible Spread Sheet Format) as used in Excel 97 thru 2002. This class simplifies POI in that it gives only read access and only for string data. Refernces to cells containing non-string-values will try to return an appropriate conversion to String.

Author:
Gerry

Constructor Summary
ExcelWrapper()
           
 
Method Summary
 int getFirstRow()
          return the index of the first row containing data
 int getLastRow()
          return the index of the last row containing data
 java.util.List<java.lang.String> getRow(int rowNr)
          Return a row of data from the sheet.
static java.lang.String getSafe(java.util.List<java.lang.String> row, int col)
          Get a Value safely (t.i: Don't thrwow an exeption if the index is tu large but return an empty string instead.
 boolean load(java.io.InputStream inputStream, int page)
          Load a specific page of the given Excel Spreadsheet
 boolean load(java.lang.String file, int page)
          Deprecated. use load(InputStream) instead
 void setFieldTypes(java.lang.Class<?>[] types)
          Set the type for each field of the calc sheet.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExcelWrapper

public ExcelWrapper()
Method Detail

load

@Deprecated
public boolean load(java.lang.String file,
                               int page)
Deprecated. use load(InputStream) instead

Load a specific page of the given Excel Spreadsheet

Parameters:
file - filename of the Excel file
page - page to use
Returns:
true on success

load

public boolean load(java.io.InputStream inputStream,
                    int page)
Load a specific page of the given Excel Spreadsheet

Parameters:
bytes - Excel content as byte array
page - page to use
Returns:
true on success

setFieldTypes

public void setFieldTypes(java.lang.Class<?>[] types)
Set the type for each field of the calc sheet. This is a hint to the parser how to convert a value. ie an Excel Number field might be interpreted as String, Integer or float value

Parameters:
types - Java Classes denoting the field types

getRow

public java.util.List<java.lang.String> getRow(int rowNr)
Return a row of data from the sheet.

Parameters:
rowNr - zero based index of the desired row
Returns:
a List of Strings with the row values or null if no such row exists.

getFirstRow

public int getFirstRow()
return the index of the first row containing data

Returns:

getLastRow

public int getLastRow()
return the index of the last row containing data

Returns:

getSafe

public static java.lang.String getSafe(java.util.List<java.lang.String> row,
                                       int col)
Get a Value safely (t.i: Don't thrwow an exeption if the index is tu large but return an empty string instead.

Parameters:
row - a List of Strings
col - index to retrieve
Returns:

Elexis API documentation
Version 2.1.6 as of December 11 2011

Copyright 2005-2011 by Gerry Weirich, Elexis