All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.excelaccessor.ExcelWorkbook

java.lang.Object
   |
   +----com.ibm.excelaccessor.ExcelWorkbook

public class ExcelWorkbook
extends Object
implements Serializable
The ExcelWorkbook class is a bean belonging to the ExcelAccessor bean suite. This class should be used along with the ExcelRange bean to access the workbook.
This class handles all the Workbook operation such as opening, saving and closing the workbook. At the time of opening the workbook, it fires the FetchPassword event if the Workbook has a protection password. It also fires this event in case the Workbook has a write reservation password and it is being opened in read-write mode. If the workbook is being opened in the write mode, this bean ignores any readOnlyRecommended status for the file. It also fires this event in case the Workbook has a structure/window protection password for the workbook modification such as inserting or removing a sheet. At the time of closing the workbook, it throws a FileSavingEvent if the file has been modified. This event could be wired to set the saveOnClose property. By default, this property is set to true (i.e. the workbook will be saved).
This bean automatically opens the workbook when it is first accessed, if it has not already been opened specifically. This class also contains methods that the other beans can call to access the excel workbook. These methods in turn call the native methods.

See Also:
FetchPasswordEvent, FetchPasswordListener, FileSavingEvent, FileSavingListener

Constructor Index

 o ExcelWorkbook()
Constructs an ExcelWorkbook with the readOnly and the saveOnClose flags set to true.

Method Index

 o addExcelWorkbookErrorListener(ExcelWorkbookErrorListener)
Add the specified ExcelWorkbookError listener to receive ExcelWorkbookError events from the ExcelWorkbook bean.
 o addExcelWorkbookListener(ExcelWorkbookListener)
Adds the specified ExcelWorkbook listener to receive ExcelWorkbook events from the ExcelWorkbook bean.
 o addFetchArgumentsListener(FetchArgumentsListener)
Adds the specified FetchArguments listener to receive FetchArgument events from the ExcelWorkbook bean.
 o addFetchPasswordListener(FetchPasswordListener)
Adds the specified FetchPassword listener to receive FetchPassword events from the ExcelWorkbook bean.
 o addFileSavingListener(FileSavingListener)
Adds the specified FileSaving listener to receive FileSaving events from the ExcelWorkbook bean.
 o addPropertyChangeListener(PropertyChangeListener)
Adds the specified PropertyChange listener to receive PropertyChange events from the ExcelWorkbook bean.
 o closeWorkbook()
The method to close the workbook.
 o finalize()
The method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
 o getThisWorkbook()
Returns the reference to this workbook.
 o getWorkbookName()
Returns the workbook name
 o getWorksheets()
Returns the worksheets in the current workbook.
 o isOpened()
Returns the status of the workbook
 o isReadOnly()
Returns the flag indicating the workbook access mode.
 o isSaveOnClose()
Returns the flag indicating whether the workbook should be saved or not.
 o openWorkbook()
This method is called to open the Workbook.
 o removeExcelWorkbookErrorListener(ExcelWorkbookErrorListener)
Removes the specified ExcelWorkbookError listener so that it no longer receives ExcelWorkbookError events from this bean.
 o removeExcelWorkbookListener(ExcelWorkbookListener)
Removes the specified ExcelWorkbook listener so that it no longer receives ExcelWorkbook events from this bean.
 o removeFetchArgumentsListener(FetchArgumentsListener)
Removes the specified FetchArguments listener so that it no longer receives FetchArguments events from this bean.
 o removeFetchPasswordListener(FetchPasswordListener)
Removes the specified FetchPassword listener so that it no longer receives FetchPassword events from this bean.
 o removeFileSavingListener(FileSavingListener)
Removes the specified FileSaving listener so that it no longer receives FileSaving events from this bean.
 o removePropertyChangeListener(PropertyChangeListener)
Removes the specified PropertyChange listener so that it no longer receives PropertyChange events from this bean.
 o setReadOnly(boolean)
Sets the flag indicating the mode that the workbook should be opened in.
 o setSaveOnClose(boolean)
Sets the flag indicating whether the workbook should be saved before closing.
 o setWorkbookName(String)
Sets the name of the workbook.
 o setWorkbookProtectionPassword(String)
Sets the Workbook ProtectionPassword.
 o setWorkbookStructureProtectionPassword(String)
Stores the Workbook StructureProtectionPassword.
 o setWorkbookWriteReservationPassword(String)
Stores the Workbook WriteReservationPassword.
 o unprotectWorkbookStructure()
This method unprotects the workbook structure/windows.

Constructors

 o ExcelWorkbook
 public ExcelWorkbook()
Constructs an ExcelWorkbook with the readOnly and the saveOnClose flags set to true.

Methods

 o addExcelWorkbookErrorListener
 public synchronized void addExcelWorkbookErrorListener(ExcelWorkbookErrorListener l)
Add the specified ExcelWorkbookError listener to receive ExcelWorkbookError events from the ExcelWorkbook bean.

Parameters:
l - The ExcelAccessorErrorListener to be added
See Also:
ExcelWorkbookErrorEvent, ExcelWorkbookErrorListener
 o addExcelWorkbookListener
 public synchronized void addExcelWorkbookListener(ExcelWorkbookListener l)
Adds the specified ExcelWorkbook listener to receive ExcelWorkbook events from the ExcelWorkbook bean.

Parameters:
l - the ExcelWorkbook listener.
See Also:
ExcelWorkbookEvent, ExcelWorkbookListener
 o addFetchArgumentsListener
 public synchronized void addFetchArgumentsListener(FetchArgumentsListener l)
Adds the specified FetchArguments listener to receive FetchArgument events from the ExcelWorkbook bean.

Parameters:
l - The FetchArgumentsListener to be added.
See Also:
FetchArgumentsEvent, FetchArgumentsListener
 o addFetchPasswordListener
 public synchronized void addFetchPasswordListener(FetchPasswordListener l)
Adds the specified FetchPassword listener to receive FetchPassword events from the ExcelWorkbook bean.

Parameters:
l - The FetchPasswordListener to be added.
See Also:
FetchPasswordEvent, FetchPasswordListener
 o addFileSavingListener
 public synchronized void addFileSavingListener(FileSavingListener l)
Adds the specified FileSaving listener to receive FileSaving events from the ExcelWorkbook bean.

Parameters:
l - the FileSaving listener.
See Also:
FileSavingEvent, FileSavingListener
 o addPropertyChangeListener
 public synchronized void addPropertyChangeListener(PropertyChangeListener l)
Adds the specified PropertyChange listener to receive PropertyChange events from the ExcelWorkbook bean.

Parameters:
l - The PropertyChangeListener to be added
See Also:
PropertyChangeEvent, PropertyChangeListener
 o closeWorkbook
 public synchronized void closeWorkbook()
The method to close the workbook. It throws a FileSavingEvent if the file has been modified. The default value of the saveOnClose flag is true. This method should be called to ensure that changes made to the workbook are not lost.

See Also:
FileSavingEvent, FileSavingListener
 o finalize
 public void finalize()
The method is called by the garbage collector on an object when garbage collection determines that there are no more references to the object. This method closes the Workbook if the workbook is open.

Overrides:
finalize in class Object
 o getWorkbookName
 public String getWorkbookName()
Returns the workbook name

Returns:
The workbook name as a String
 o isOpened
 public boolean isOpened()
Returns the status of the workbook

Returns:
Returns true if the workbook is open
 o getThisWorkbook
 public ExcelWorkbook getThisWorkbook()
Returns the reference to this workbook.

Returns:
The this workbook reference
 o getWorksheets
 public synchronized String[] getWorksheets()
Returns the worksheets in the current workbook. This method must be called only after the workbook is open.

Returns:
The array of Strings that contains the list of worksheets. null if the workbook is not open.
 o openWorkbook
 public synchronized void openWorkbook()
This method is called to open the Workbook. The method throws the FetchPassword events if the passwords are required. The workbook can be open in readonly or read/write mode as desired. If workbook is opened successfully it fires the workbookOpened (ExcelWorkbookEvent) event to indicate the success. If the workbook is opened successfully than it reads the name of all the worksheets in this workbook. This method throws ExcelWorkbookError event if any error occurs.

See Also:
FetchPasswordListener, ExcelWorkbookErrorListener
 o removeExcelWorkbookErrorListener
 public synchronized void removeExcelWorkbookErrorListener(ExcelWorkbookErrorListener l)
Removes the specified ExcelWorkbookError listener so that it no longer receives ExcelWorkbookError events from this bean.

Parameters:
l - The ExcelWorkbookErrorListener to be removed
See Also:
ExcelWorkbookErrorEvent, ExcelWorkbookErrorListener
 o removeExcelWorkbookListener
 public synchronized void removeExcelWorkbookListener(ExcelWorkbookListener l)
Removes the specified ExcelWorkbook listener so that it no longer receives ExcelWorkbook events from this bean.

Parameters:
l - The ExcelWorkbookListener to be removed
See Also:
ExcelWorkbookEvent, ExcelWorkbookListener
 o removeFetchArgumentsListener
 public synchronized void removeFetchArgumentsListener(FetchArgumentsListener l)
Removes the specified FetchArguments listener so that it no longer receives FetchArguments events from this bean.

Parameters:
l - The FetchArgumentsListener to be removed
See Also:
FetchArgumentsEvent, FetchArgumentsListener
 o removeFetchPasswordListener
 public synchronized void removeFetchPasswordListener(FetchPasswordListener l)
Removes the specified FetchPassword listener so that it no longer receives FetchPassword events from this bean.

Parameters:
l - The FetchPasswordListener to be removed
See Also:
FetchPasswordEvent, FetchPasswordListener
 o removeFileSavingListener
 public synchronized void removeFileSavingListener(FileSavingListener l)
Removes the specified FileSaving listener so that it no longer receives FileSaving events from this bean.

Parameters:
l - The FileSavingListener to be removed
See Also:
FileSavingEvent, FileSavingListener
 o removePropertyChangeListener
 public synchronized void removePropertyChangeListener(PropertyChangeListener l)
Removes the specified PropertyChange listener so that it no longer receives PropertyChange events from this bean.

Parameters:
listener - The PropertyChangeListener to be removed
See Also:
PropertyChangeEvent, PropertyChangeListener
 o isReadOnly
 public boolean isReadOnly()
Returns the flag indicating the workbook access mode.

Returns:
The readOnly property
 o isSaveOnClose
 public boolean isSaveOnClose()
Returns the flag indicating whether the workbook should be saved or not.

Returns:
The saveOnClose property
 o setReadOnly
 public void setReadOnly(boolean b)
Sets the flag indicating the mode that the workbook should be opened in. This method closes the workbook if it is currently open. The default value of this property is true.

Parameters:
b - The boolean parameter
 o setSaveOnClose
 public void setSaveOnClose(boolean b)
Sets the flag indicating whether the workbook should be saved before closing. The default value of this property is true.

Parameters:
b - The boolean parameter
 o setWorkbookName
 public void setWorkbookName(String name)
Sets the name of the workbook. This method closes the workbook if it is currently open.

Parameters:
name - The String specifying the workbookName
 o setWorkbookProtectionPassword
 public void setWorkbookProtectionPassword(String pass)
Sets the Workbook ProtectionPassword.

Parameters:
pass - The String specifying the workbookProtection password
 o setWorkbookStructureProtectionPassword
 public void setWorkbookStructureProtectionPassword(String pass)
Stores the Workbook StructureProtectionPassword.

Parameters:
pass - The String specifying the workbookStructureProtection password
 o setWorkbookWriteReservationPassword
 public void setWorkbookWriteReservationPassword(String pass)
Stores the Workbook WriteReservationPassword.

Parameters:
pass - The String specifying the workbookWriteReservationProtection password
 o unprotectWorkbookStructure
 public synchronized void unprotectWorkbookStructure()
This method unprotects the workbook structure/windows. The method throws the FetchPassword event if a password is required.

See Also:
FetchPasswordListener

All Packages  Class Hierarchy  This Package  Previous  Next  Index