de.bezier.data
Class XlsReader

java.lang.Object
  extended by de.bezier.data.XlsReader

public class XlsReader
extends java.lang.Object

XlsReader, a reader for .xls files (OpenOffice, Microsoft Excel) based on the Apache POI library.

" Apache POI - Java API To Access Microsoft Format Files"
Apache POI QuickRef Apache POI Documentation


Creative Commons License This work is licensed under a Creative Commons Attribution-Share Alike 2.0 Germany License . "Excel" and "Office" are trademarks of Microsoft Corporation.

Author:
fjenett 20081129

Constructor Summary
XlsReader(processing.core.PApplet thePapplet, java.lang.String theXlsFile)
          XlsReader constructor.
 
Method Summary
 void firstCell()
          Jump to the first cell of a row.
 void firstRow()
          Jump to the first row of a sheet.
 int getCellNum()
          Returns the index of the currently selected cell.
 int getFirstRowNum()
          Read the index of the first not empty row of the current sheet.
 float getFloat()
          Return a float value from the selected cell of the selected row of current sheet.
 float getFloat(int rowNum, int cellNum)
          Return an float value from a specific cell of the current sheet.
 int getInt()
          Return an int value from the selected cell of the selected row of current sheet.
 int getInt(int rowNum, int cellNum)
          Return an int value from a specific cell of the current sheet.
 int getLastRowNum()
          Read the index of the last available row of the current sheet.
 int getRowNum()
          Read the index of the current row of the current sheet.
 java.lang.String getString()
          Return a String value from the selected cell of the selected row of current sheet.
 java.lang.String getString(int rowNum, int cellNum)
          Return a string value (text) from a specific cell of the current sheet.
 boolean hasMoreCells()
          Check if the cell iterator has more cells available to be read for the current row.
 boolean hasMoreRows()
          Check if the row iterator has more row available to be read.
 void nextCell()
          Select the next (or first) cell of the selected row of current sheet.
 void nextRow()
          Select the next (or first) row of current sheet.
 void openSheet(int page)
          Jump to a different page (sheet) inside of the xls file.
 void resetCell()
          Select no cell of the selected row of current sheet.
 void showWarnings(boolean enable)
          Enable or diable warnings.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XlsReader

public XlsReader(processing.core.PApplet thePapplet,
                 java.lang.String theXlsFile)
XlsReader constructor.

Parameters:
thePapplet - Normally just pass "this", which is your sketch
theXlsFile - Path to xls file
Method Detail

showWarnings

public void showWarnings(boolean enable)
Enable or diable warnings. Consider fixing your code rather than just diabling the warnings.

Parameters:
enable - Turn warnings on or off.

openSheet

public void openSheet(int page)
Jump to a different page (sheet) inside of the xls file. The default page is page 1 (at address 0).

Parameters:
page - Page / sheet number to jump to, first page is at 0

getFirstRowNum

public int getFirstRowNum()
Read the index of the first not empty row of the current sheet.

Returns:
int The index of the first row of this sheet or -1

getRowNum

public int getRowNum()
Read the index of the current row of the current sheet.

Returns:
int The index of the currently selected row of this sheet or -1

getLastRowNum

public int getLastRowNum()
Read the index of the last available row of the current sheet. Rows inbetween might be empty.

Returns:
int The index of the last row of this sheet or -1

firstRow

public void firstRow()
Jump to the first row of a sheet.


nextRow

public void nextRow()
Select the next (or first) row of current sheet. First cell of that row will be selected automatically.


hasMoreRows

public boolean hasMoreRows()
Check if the row iterator has more row available to be read.

This can be used in while() loops

        while ( reader.hasMoreRows() ) {
                // jump to the next row
                reader.nextRow();

                // read cell, eventually loop cells with another while() loop.
        }

Returns:
boolean True if more rows are available, false if last row is reached

hasMoreCells

public boolean hasMoreCells()
Check if the cell iterator has more cells available to be read for the current row.

This can be used in while() loops

        while ( reader.hasMoreCells() ) {
                // jump to the next cell
                reader.nextCell();

                // read cell value
        }

Returns:
boolean True if more cells are available, false if last cell is reached

getCellNum

public int getCellNum()
Returns the index of the currently selected cell.

Returns:
int Index of the currently selected cell or -1

resetCell

public void resetCell()
Select no cell of the selected row of current sheet. This is needed with firstCell() and nextCell().


firstCell

public void firstCell()
Jump to the first cell of a row.


nextCell

public void nextCell()
Select the next (or first) cell of the selected row of current sheet.


getString

public java.lang.String getString()
Return a String value from the selected cell of the selected row of current sheet.

Returns:
String The String value of that cell.

getInt

public int getInt()
Return an int value from the selected cell of the selected row of current sheet.

Returns:
int The int value of that cell.

getFloat

public float getFloat()
Return a float value from the selected cell of the selected row of current sheet.

Returns:
float The float value of that cell.

getInt

public int getInt(int rowNum,
                  int cellNum)
Return an int value from a specific cell of the current sheet.

Parameters:
rowNum - Row (vertically) to read from. First row is 0.
cellNum - Cell (horizontal) in the row to read from. Starts at 0.
Returns:
int The int value of that cell.

getFloat

public float getFloat(int rowNum,
                      int cellNum)
Return an float value from a specific cell of the current sheet.

Parameters:
rowNum - Row (vertically) to read from. First row is 0.
cellNum - Cell (horizontal) in the row to read from. Starts at 0.
Returns:
float The float value of that cell.

getString

public java.lang.String getString(int rowNum,
                                  int cellNum)
Return a string value (text) from a specific cell of the current sheet.

Parameters:
rowNum - Row (vertically) to read from. First row is 0.
cellNum - Cell (horizontal) in the row to read from. Starts at 0.
Returns:
String The string value of that cell.


processing library XlsReader by Florian Jenett. (c) 2007 - 2011