ExcelAccessor Bean Suite

com.ibm.excelaccessor
Class ExcelWorkbook

java.lang.Object
  |
  +--com.ibm.excelaccessor.ExcelWorkbook
All Implemented Interfaces:
java.io.Serializable

public class ExcelWorkbook
extends java.lang.Object
implements java.io.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, Serialized Form

Field Summary
protected  java.beans.PropertyChangeSupport propertyChange
           
 
Constructor Summary
ExcelWorkbook()
          Constructs an ExcelWorkbook with the readOnly and the saveOnClose flags set to true.
 
Method Summary
 void addExcelWorkbookErrorListener(ExcelWorkbookErrorListener l)
          Add the specified ExcelWorkbookError listener to receive ExcelWorkbookError events from the ExcelWorkbook bean.
 void addExcelWorkbookListener(ExcelWorkbookListener l)
          Adds the specified ExcelWorkbook listener to receive ExcelWorkbook events from the ExcelWorkbook bean.
 void addFetchArgumentsListener(FetchArgumentsListener l)
          Adds the specified FetchArguments listener to receive FetchArgument events from the ExcelWorkbook bean.
 void addFetchPasswordListener(FetchPasswordListener l)
          Adds the specified FetchPassword listener to receive FetchPassword events from the ExcelWorkbook bean.
 void addFileSavingListener(FileSavingListener l)
          Adds the specified FileSaving listener to receive FileSaving events from the ExcelWorkbook bean.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Adds the specified PropertyChange listener to receive PropertyChange events from the ExcelWorkbook bean.
 void closeExcelApplication()
          The method to close the application.
 void closeWorkbook()
          The method to close the workbook.
 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.
 void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          The firePropertyChange method was generated to support the propertyChange field.
 java.lang.String getAboutThisBean()
           
protected  java.beans.PropertyChangeSupport getPropertyChange()
          Accessor for the propertyChange field.
 ExcelWorkbook getThisWorkbook()
          Returns the reference to this workbook.
 java.lang.String getWorkbookName()
          Returns the workbook name
 java.lang.String[] getWorksheets()
          Returns the worksheets in the current workbook.
 boolean isExcelfile(java.lang.String file_name)
          This method was created in VisualAge.
 boolean isOpened()
          Returns the status of the workbook
 boolean isReadOnly()
          Returns the flag indicating the workbook access mode.
 boolean isSaveOnClose()
          Returns the flag indicating whether the workbook should be saved or not.
 void newWorkbook()
          This method is called to create the new Workbook.
 void openWorkbook()
          This method is called to open the Workbook.
 void removeExcelWorkbookErrorListener(ExcelWorkbookErrorListener l)
          Removes the specified ExcelWorkbookError listener so that it no longer receives ExcelWorkbookError events from this bean.
 void removeExcelWorkbookListener(ExcelWorkbookListener l)
          Removes the specified ExcelWorkbook listener so that it no longer receives ExcelWorkbook events from this bean.
 void removeFetchArgumentsListener(FetchArgumentsListener l)
          Removes the specified FetchArguments listener so that it no longer receives FetchArguments events from this bean.
 void removeFetchPasswordListener(FetchPasswordListener l)
          Removes the specified FetchPassword listener so that it no longer receives FetchPassword events from this bean.
 void removeFileSavingListener(FileSavingListener l)
          Removes the specified FileSaving listener so that it no longer receives FileSaving events from this bean.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Removes the specified PropertyChange listener so that it no longer receives PropertyChange events from this bean.
 void setAboutThisBean(java.lang.String aboutThisBean)
           
 void setReadOnly(boolean b)
          Sets the flag indicating the mode that the workbook should be opened in.
 void setSaveOnClose(boolean b)
          Sets the flag indicating whether the workbook should be saved before closing.
 void setWorkbookName(java.lang.String name)
          Sets the name of the workbook.
 void setWorkbookProtectionPassword(java.lang.String pass)
          Sets the Workbook ProtectionPassword.
 void setWorkbookStructureProtectionPassword(java.lang.String pass)
          Stores the Workbook StructureProtectionPassword.
 void setWorkbookWriteReservationPassword(java.lang.String pass)
          Stores the Workbook WriteReservationPassword.
 void unprotectWorkbookStructure()
          This method unprotects the workbook structure/windows.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

propertyChange

protected transient java.beans.PropertyChangeSupport propertyChange
Constructor Detail

ExcelWorkbook

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

addExcelWorkbookErrorListener

public 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

addExcelWorkbookListener

public 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

addFetchArgumentsListener

public 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

addFetchPasswordListener

public 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

addFileSavingListener

public 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

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.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

closeExcelApplication

public void closeExcelApplication()
The method to close the application.
See Also:
FileSavingEvent, FileSavingListener

closeWorkbook

public 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

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 java.lang.Object

firePropertyChange

public void firePropertyChange(java.lang.String propertyName,
                               java.lang.Object oldValue,
                               java.lang.Object newValue)
The firePropertyChange method was generated to support the propertyChange field.

getAboutThisBean

public java.lang.String getAboutThisBean()

getPropertyChange

protected java.beans.PropertyChangeSupport getPropertyChange()
Accessor for the propertyChange field.

getThisWorkbook

public ExcelWorkbook getThisWorkbook()
Returns the reference to this workbook.
Returns:
The this workbook reference

getWorkbookName

public java.lang.String getWorkbookName()
Returns the workbook name
Returns:
The workbook name as a String

getWorksheets

public java.lang.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.

isExcelfile

public boolean isExcelfile(java.lang.String file_name)
This method was created in VisualAge.
Returns:
boolean

isOpened

public boolean isOpened()
Returns the status of the workbook
Returns:
Returns true if the workbook is open

isReadOnly

public boolean isReadOnly()
Returns the flag indicating the workbook access mode.
Returns:
The readOnly property

isSaveOnClose

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

newWorkbook

public void newWorkbook()
This method is called to create the new Workbook. The method throws the FetchPassword events if the passwords are required. The workbook can be open only in write mode. 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:
ExcelWorkbookErrorListener

openWorkbook

public 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

removeExcelWorkbookErrorListener

public 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

removeExcelWorkbookListener

public 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

removeFetchArgumentsListener

public 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

removeFetchPasswordListener

public 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

removeFileSavingListener

public 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

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.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

setAboutThisBean

public void setAboutThisBean(java.lang.String aboutThisBean)

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

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

setWorkbookName

public void setWorkbookName(java.lang.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

setWorkbookProtectionPassword

public void setWorkbookProtectionPassword(java.lang.String pass)
Sets the Workbook ProtectionPassword.
Parameters:
pass - The String specifying the workbookProtection password

setWorkbookStructureProtectionPassword

public void setWorkbookStructureProtectionPassword(java.lang.String pass)
Stores the Workbook StructureProtectionPassword.
Parameters:
pass - The String specifying the workbookStructureProtection password

setWorkbookWriteReservationPassword

public void setWorkbookWriteReservationPassword(java.lang.String pass)
Stores the Workbook WriteReservationPassword.
Parameters:
pass - The String specifying the workbookWriteReservationProtection password

unprotectWorkbookStructure

public void unprotectWorkbookStructure()
This method unprotects the workbook structure/windows. The method throws the FetchPassword event if a password is required.
See Also:
FetchPasswordListener

ExcelAccessor Bean Suite

ExcelAccessor Bean Suite