com.jniwrapper.win32.jexcel
Class Worksheet

java.lang.Object
  extended by com.jniwrapper.win32.jexcel.Worksheet
All Implemented Interfaces:
com.jniwrapper.AutoDeleteParameter

public class Worksheet
extends java.lang.Object

This class provides functionality for working with an Excel worksheet.


Method Summary
 void activate()
          Activates the worksheet.
 void addWorksheetEventListener(WorksheetEventListener eventListener)
          Adds the listener of worksheet events.
 void clear()
          Clears all cells of the worksheet.
 void deleteColumn(Range column)
          Deletes specified column
 void deleteColumn(java.lang.String column)
          Deletes specified column.
 void deleteRow(int rowIndex)
          Deletes specified row.
 void deleteRow(Range row)
          Deletes specified row.
 void displayHeadings(boolean visible)
          Allows hide and display worksheet headings.
 boolean equals(java.lang.Object obj)
           
 void fillWithArray(Cell startCell, java.util.Date[][] content)
          Fills range, starting at given cell with given array.
 void fillWithArray(Cell startCell, double[][] content)
          Fills range, starting at given cell with given array.
 void fillWithArray(Cell startCell, long[][] content)
          Fills range, starting at given cell with given array.
 void fillWithArray(Cell startCell, java.lang.String[][] content)
          Fills range, starting at given cell with given array.
 void fillWithArray(java.lang.String range, java.util.Date[][] content)
          Fills range with given array.
 void fillWithArray(java.lang.String range, java.util.Date[][] content, java.text.DateFormat dateFormat)
          Fills range with given array.
 void fillWithArray(java.lang.String range, double[][] content)
          Fills range with given array.
 void fillWithArray(java.lang.String range, long[][] content)
          Fills range with given array.
 void fillWithArray(java.lang.String range, java.lang.String[][] content)
          Fills range with given array.
 void fillWithArray(java.lang.String range, com.jniwrapper.win32.automation.types.Variant[][] content)
          Fills range with given array.
 Application getApplication()
          Returns the application object.
 Cell getCell(int row, int column)
          Returns an instance of the Cell class that represents the specified cell.
 Cell getCell(java.lang.String cell)
          Returns an instance of the Cell class that represents the specified cell.
 Range getColumn(java.lang.String column)
          Returns the Range that contains all cells of the specified column.
 Range getColumns(java.lang.String[] columns)
          Returns the Range that contains all cells of the specified columns.
 int getIndex()
          Returns the index of the worksheet.
 java.lang.String getName()
          Returns the name of the worksheet.
 com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
          Returns the message loop thread for processing native peer function calls.
 Workbook getParent()
          Returns the parent workbook.
 com.jniwrapper.win32.excel._Worksheet getPeer()
          Returns the appropriate native peer.
 Range getRange(java.lang.String range)
          Creates an instance of the Range class that contains cells of the specified range.
 Range getRow(int row)
          Returns the Range that contains all cells of the specified row.
 Range getRows(int[] rows)
          Returns the Range that contains all cells of the specified rows.
 Range getUsedRange()
          Returns the Range that contains used cells of the worksheet.
 void insertColumnAfter(Range column)
          Inserts new empty column after specified column.
 void insertColumnAfter(java.lang.String column)
          Inserts new empty column after specified column
 void insertColumnBefore(Range column)
          Inserts new empty column before specified column.
 void insertColumnBefore(java.lang.String column)
          Inserts new empty column before specified column.
 void insertRowAfter(int rowIndex)
          Inserts new empty row after specified row.
 void insertRowAfter(Range row)
          Inserts new empty row after specified row.
 void insertRowBefore(int rowIndex)
          Inserts new empty row before specified row.
 void insertRowBefore(Range row)
          Inserts new empty row before specified row.
 boolean isAutoDelete()
           
 boolean isVisible()
          Returns true if the worksheet is visible.
 void print(int copies)
          Prints the specified number of copies of the worksheet.
 void protect(java.lang.String password)
          Protects worksheet by password.
 void recalculateAllFormulas()
          Recalculates all formulas.
 void release()
          Releases this wrapper object.
 void removeEventHandler()
          Removes the handler of worksheet events.
 void removeWorksheetEventListener(WorksheetEventListener eventListener)
          Removes the specified listener of worksheet events.
 Range selectAll()
          Returns the Range that contains all cells of the worksheet.
 void setAutoDelete(boolean value)
           
 void setEventHandler(WorksheetEventHandler eventHandler)
          Specifies the handler of worksheet events.
 void setName(java.lang.String name)
          Changes the name of the worksheet.
protected  void setOleMessageLoop(com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)
           
 void setVisible(boolean visible)
          Shows or hides the worksheet.
 java.lang.String toString()
           
 void unprotect(java.lang.String password)
          Unprotects worksheet by password.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

setName

public void setName(java.lang.String name)
Changes the name of the worksheet.

Parameters:
name - is a new worksheet name.
Throws:
java.lang.IllegalArgumentException - if the name is null.

getName

public java.lang.String getName()
Returns the name of the worksheet.

Returns:
the name of the worksheet.

getIndex

public int getIndex()
Returns the index of the worksheet.

Returns:
the index of the worksheet.

print

public void print(int copies)
           throws javax.print.PrintException
Prints the specified number of copies of the worksheet.

Parameters:
copies - is the number of copies to be printed.
Throws:
java.lang.IllegalArgumentException - if the number of copies is negative.
javax.print.PrintException - if print problems occured.

protect

public void protect(java.lang.String password)
Protects worksheet by password. The worksheet will be read only.

Parameters:
password - protection password

unprotect

public void unprotect(java.lang.String password)
Unprotects worksheet by password. The worksheet will be writable.

Parameters:
password - protection password

clear

public void clear()
Clears all cells of the worksheet.


setVisible

public void setVisible(boolean visible)
Shows or hides the worksheet.

Parameters:
visible - if true the worksheet becomes visible.

displayHeadings

public void displayHeadings(boolean visible)
Allows hide and display worksheet headings.

Parameters:
visible - - specifies displaying state

isVisible

public boolean isVisible()
Returns true if the worksheet is visible.

Returns:
true if the worksheet is visible.

getParent

public Workbook getParent()
Returns the parent workbook.

Returns:
the parent workbook.

activate

public void activate()
Activates the worksheet.


recalculateAllFormulas

public void recalculateAllFormulas()
Recalculates all formulas.


setEventHandler

public void setEventHandler(WorksheetEventHandler eventHandler)
Specifies the handler of worksheet events.

Parameters:
eventHandler -

removeEventHandler

public void removeEventHandler()
Removes the handler of worksheet events.


addWorksheetEventListener

public void addWorksheetEventListener(WorksheetEventListener eventListener)
Adds the listener of worksheet events.

Parameters:
eventListener -

removeWorksheetEventListener

public void removeWorksheetEventListener(WorksheetEventListener eventListener)
Removes the specified listener of worksheet events.

Parameters:
eventListener - is the listener to be removed.

selectAll

public Range selectAll()
Returns the Range that contains all cells of the worksheet.

Returns:
the Range that contains all cells of the worksheet.

getUsedRange

public Range getUsedRange()
Returns the Range that contains used cells of the worksheet.

Returns:
the Range that contains used cells of the worksheet.

fillWithArray

public void fillWithArray(Cell startCell,
                          java.lang.String[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range, starting at given cell with given array.

Parameters:
startCell - specifies the top-left cell of the range that should be filled with given array
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          java.lang.String[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations.

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          com.jniwrapper.win32.automation.types.Variant[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations.

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(Cell startCell,
                          double[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range, starting at given cell with given array.

Parameters:
startCell - specifies the top-left cell of the range that should be filled with given array
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          double[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(Cell startCell,
                          long[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range, starting at given cell with given array.

Parameters:
startCell - specifies the top-left cell of the range that should be filled with given array
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          long[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(Cell startCell,
                          java.util.Date[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range, starting at given cell with given array.

Parameters:
startCell - specifies the top-left cell of the range that should be filled with given array
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          java.util.Date[][] content,
                          java.text.DateFormat dateFormat)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

fillWithArray

public void fillWithArray(java.lang.String range,
                          java.util.Date[][] content)
                   throws java.lang.IndexOutOfBoundsException
Fills range with given array. The method uses setValue2() method for quick bulk operations

Parameters:
range - specifies range to be filled
content - array with values
Throws:
java.lang.IndexOutOfBoundsException

getColumn

public Range getColumn(java.lang.String column)
Returns the Range that contains all cells of the specified column.

Parameters:
column - specifies the column.
Returns:
the Range that contains all cells of the specified column.
Throws:
java.lang.IllegalArgumentException - if the target column is null or Excel unable to get the specified column.

getColumns

public Range getColumns(java.lang.String[] columns)
Returns the Range that contains all cells of the specified columns.

Parameters:
columns - specifies the columns.
Returns:
the Range that contains all cells of the specified columns.
Throws:
java.lang.IllegalArgumentException - the columns argument is null or Excel unable to get any of columns.

getRow

public Range getRow(int row)
Returns the Range that contains all cells of the specified row.

Parameters:
row - specifies the row.
Returns:
the Range that contains all cells of the specified row.
Throws:
java.lang.IllegalArgumentException - if the row argument is negative or Excel unable to get the specified row.

getRows

public Range getRows(int[] rows)
Returns the Range that contains all cells of the specified rows.

Parameters:
rows - specifies the rows.
Returns:
the Range that contains all cells of the specified rows.
Throws:
java.lang.IllegalArgumentException - if the rows argument is null or Excel unable to get any of rows.

getRange

public Range getRange(java.lang.String range)
Creates an instance of the Range class that contains cells of the specified range.

Parameters:
range - is a string representation of a range of cells or a name of a named range.
Returns:
an instance of the Range class that contains cells of the specified range.
Throws:
java.lang.IllegalArgumentException - if the range value is null or illegal.

getCell

public Cell getCell(java.lang.String cell)
Returns an instance of the Cell class that represents the specified cell.

Parameters:
cell - specifies the cell.
Returns:
an instance of the Cell class that represents the specified cell.
Throws:
java.lang.IllegalArgumentException - if the cell value is null or illegal.

getCell

public Cell getCell(int row,
                    int column)
Returns an instance of the Cell class that represents the specified cell.

Parameters:
row - specifies the row index.
column - specifies the column name.
Returns:
an instance of the Cell class that represents the specified cell.
Throws:
java.lang.IndexOutOfBoundsException - if any index is non-positive or illegal.

insertRowBefore

public void insertRowBefore(int rowIndex)
Inserts new empty row before specified row.

Parameters:
rowIndex - index of row before which empty row will be inserted.

insertRowAfter

public void insertRowAfter(int rowIndex)
Inserts new empty row after specified row.

Parameters:
rowIndex - index of row after which empty row will be inserted.

insertRowBefore

public void insertRowBefore(Range row)
Inserts new empty row before specified row.

Parameters:
row - specifies the row before which empty row will be inserted.

insertRowAfter

public void insertRowAfter(Range row)
Inserts new empty row after specified row.

Parameters:
row - specifies the row after which empty row will be inserted.

insertColumnBefore

public void insertColumnBefore(java.lang.String column)
Inserts new empty column before specified column.

Parameters:
column - index of column before which empty column will be inserted.

insertColumnAfter

public void insertColumnAfter(java.lang.String column)
Inserts new empty column after specified column

Parameters:
column - index of column after which empty column will be inserted.

insertColumnBefore

public void insertColumnBefore(Range column)
Inserts new empty column before specified column.

Parameters:
column - specifies the column before which empty column will be inserted.

insertColumnAfter

public void insertColumnAfter(Range column)
Inserts new empty column after specified column.

Parameters:
column - specifies the column after which empty column will be inserted.

deleteColumn

public void deleteColumn(java.lang.String column)
Deletes specified column.

Parameters:
column - index of column which will be deleted.

deleteColumn

public void deleteColumn(Range column)
Deletes specified column

Parameters:
column - specifies the column which will be deleted.

deleteRow

public void deleteRow(int rowIndex)
Deletes specified row.

Parameters:
rowIndex - index of row which will be deleted.

deleteRow

public void deleteRow(Range row)
Deletes specified row.

Parameters:
row - specifies the row which will be deleted.

getPeer

public com.jniwrapper.win32.excel._Worksheet getPeer()
Returns the appropriate native peer.

Returns:
the appropriate native peer.

release

public void release()
Releases this wrapper object.


equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

getApplication

public Application getApplication()
Returns the application object.

Returns:
the application.

getOleMessageLoop

public com.jniwrapper.win32.automation.OleMessageLoop getOleMessageLoop()
Returns the message loop thread for processing native peer function calls.

Returns:
the message loop thread for processing native peer function calls.

setOleMessageLoop

protected void setOleMessageLoop(com.jniwrapper.win32.automation.OleMessageLoop oleMessageLoop)

setAutoDelete

public void setAutoDelete(boolean value)
Specified by:
setAutoDelete in interface com.jniwrapper.AutoDeleteParameter

isAutoDelete

public boolean isAutoDelete()
Specified by:
isAutoDelete in interface com.jniwrapper.AutoDeleteParameter

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object