|
ExcelAccessor Bean Suite | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.ibm.excelaccessor.ExcelRange
This bean represents an Excel range and is used to access that range from the ExcelWorkbook supplied to this range. This bean uses the facilities provided by the ExcelWorkbook bean to access the range. The sheet name and the range name identify the range. The user of this bean needs to initialize (turn on) this bean before it can be used for accessing the range properties. Once the bean has been initialized, setting the properties of the range writes to the file.
The following major properties of the range can be accessed using the ExcelRange bean:
Value: This property is the raw value of the cell without any information as to how the value is formatted or whether the value is the result of a formula evaluation. The various types of values returned are Strings, Double, Dates, Boolean. Blank cells are returned as blank Strings. Even time and currency values are returned as Double values.
Formula: This property returns the formula String for each cell. If a particular cell does not contain a formula, the value of the formula property is the constant in the cell, represented as a String.
Format: This property is the format string for the range.
NoteText: This is the note text property of the range.
In the ExcelRange bean, it is possible to specify the range both by giving the range name or the row/column numbers of the range. This bean provides output that is same as the output which would have been available had the particular property of the range been accessed using Excel APIs directly. The value property can be read as the actual type of value (String, Date, Boolean or Double) and can be written both as the actual type of value and as Strings. It is not possible to write to cells that are parts of an array using this bean.
This bean also provides features to clear the contents (either some or all of the above properties) of a range, to check whether the specified cell is part of an Array, to check whether the specified cell contains a Formula, to find the dimensions of the range and insertion and removal of worksheets in a workbook. It is also possible to unprotect worksheets in a workbook using this bean.
A single instance of the range bean can be used to access different ranges. Calling the setter for the range name (or selecting a different range using row and column numbers) results in the range bean getting uninitialized.initRange has to be invoked again to initialize the range.
| Field Summary | |
protected java.beans.PropertyChangeSupport |
propertyChange
|
| Constructor Summary | |
ExcelRange()
Constructs an ExcelRange object with properties autoCreateSheet and autoUnprotectSheet set to false. |
|
| Method Summary | |
void |
addExcelRangeErrorListener(ExcelRangeErrorListener l)
Adds the specified ExcelRangeErrorListener to receive ExcelRangeError events from the ExcelRange bean. |
void |
addExcelRangeListener(ExcelRangeListener l)
Adds the specified ExcelRangeListener to receive ExcelRange events from the ExcelRange bean. |
void |
addExcelSheetListener(ExcelSheetListener l)
Adds the specified ExcelSheetListener to receive ExcelSheet events from the ExcelRange bean. |
void |
addFetchArgumentsListener(FetchArgumentsListener l)
Adds the specified FetchArgumentsListener to receive FetchArguments events from the ExcelRange bean. |
void |
addFetchPasswordListener(FetchPasswordListener l)
Adds the specified FetchPasswordListener to receive FetchPassword events from the ExcelRange bean. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Adds the specified PropertyChangeListener to receive PropertyChange events from the ExcelRange bean. |
void |
clear()
Clears all the cell properties (value, formula, format, text and noteText) for this Range. |
void |
clearContents()
Clears the cell contents (values and formulae, if any) for this Range. |
void |
clearFormats()
Clears all cell formatting information for all the cells in the range, the values, noteText and formulae are retained. |
void |
clearNotes()
Clears all the notes for all the cells in the range, the value, formula and format information are retained. |
void |
createNamedRange(java.lang.String name)
Assigns a name to the current range. |
void |
fillExcelFormatModel()
Fills the ExcelFormatModel bean from the range. |
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()
Gets the aboutThisBean property (java.lang.String) value. |
boolean |
getAutoGetUsedRange()
Gets the autoGetUsedRange property (boolean) value. |
java.util.Vector |
getColumnHeaders()
Returns a Vector of Strings, which represents the headers of the columns of the range (as integers). |
java.lang.String |
getDefaultText()
Returns the text property of the range as returned by Excel. |
int |
getEndCol()
Returns the column number for the bottom right cell of the range. |
int |
getEndRow()
Returns the row number for the bottom right cell of the range. |
ExcelFormatModel |
getExcelFormatModel()
Gets the excelFormatModel property (com.ibm.excelaccessor.ExcelFormatModel) value. |
java.lang.String |
getFormat()
Returns the Format property of the range as a String. |
java.util.Vector |
getFormula()
Returns the Formula property for the Range as a Vector of Vectors. |
java.lang.Object |
getFormulaAsArray()
Returns the formula property as a 2-Dimensional array of objects. |
int |
getNCols()
Returns the number of columns present in the range. |
java.lang.String |
getNoteText()
Returns the noteText for the top-left cell of the range. |
int |
getNRows()
Returns the number of rows present in the range. |
protected java.beans.PropertyChangeSupport |
getPropertyChange()
Accessor for the propertyChange field. |
java.lang.String |
getRangeName()
Returns the name of the range if the range has been selected using rangeName. |
java.util.Vector |
getRowHeaders()
Returns a Vector of Strings, which represents the headers of the rows of the range (as integers). |
int |
getStartCol()
Returns the column number for the top left cell of the range. |
int |
getStartRow()
Returns the row number for the top left cell of the range. |
java.util.Vector |
getText()
Returns the Text property for the Range. |
java.util.Vector |
getValue()
Returns the Value property for the Range. |
java.lang.Object |
getValueAsArray()
Returns the value property as a 2-Dimensional array of objects. |
java.lang.String |
getWorksheetName()
Returns the name of the worksheet. |
java.lang.Boolean |
hasArray()
Method to check whether the range is part of an array. |
java.lang.Boolean |
hasFormula()
Method to check whether the cells in the range contain formulae. |
void |
initRange()
A call to this method initializes the range and essentially turns it on for further use. |
void |
insertWorksheet()
Inserts a new worksheet in the workbook and renames it to the worksheetName of this range. |
boolean |
isAutoCreateSheet()
Returns the value of the autoCreateSheet property. |
boolean |
isAutoUnprotectSheet()
Returns the value of the autoUnprotectSheet property. |
boolean |
isInitialized()
Returns the status of the initialization of the range bean. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
The listener method for property change events. |
void |
removeExcelRangeErrorListener(ExcelRangeErrorListener l)
Removes the specified ExcelRangeErrorListener so that it no longer receives ExcelRangeErrorEvents from this bean. |
void |
removeExcelRangeListener(ExcelRangeListener l)
Removes the specified ExcelRangeListener so that it no longer receives ExcelRangeEvents from this bean. |
void |
removeExcelSheetListener(ExcelSheetListener l)
Removes the specified ExcelSheetListener so that it no longer receives ExcelSheetEvents from this bean. |
void |
removeFetchArgumentsListener(FetchArgumentsListener l)
Removes the specified FetchArgumentsListener so that it no longer receives FetchArgumentsEvents from this bean. |
void |
removeFetchPasswordListener(FetchPasswordListener l)
Removes the specified FetchPasswordListener so that it no longer receives FetchPasswordEvents from this bean. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Removes the specified PropertyChangeListener so that it no longer receives PropertyChangeEvents from this bean. |
void |
removeWorksheet()
Removes a worksheet from the workbook. |
void |
saveExcelFormatModel()
Saves the content of the contained ExcelFormatModel bean to the range. |
void |
setAboutThisBean(java.lang.String aboutThisBean)
Sets the aboutThisBean property (java.lang.String) value. |
void |
setAutoCreateSheet(boolean bValue)
Sets the value of the autoCreateSheet property. |
void |
setAutoGetUsedRange(boolean autoGetUsedRange)
Sets the autoGetUsedRange property (boolean) value. |
void |
setAutoUnprotectSheet(boolean bValue)
Sets the value of the autoUnprotectSheet property. |
void |
setCellR1C1(int row,
int col)
This method can be used to identify a single cell as the range to be accessed using the cell row and column numbers. |
void |
setExcelFormatModel(ExcelFormatModel excelFormatModel)
Sets the excelFormatModel property (com.ibm.excelaccessor.ExcelFormatModel) value. |
void |
setFormat(java.lang.String strFormat)
Sets the format property of this Range. |
void |
setFormula(java.util.Vector objFormula)
Sets the formula property of this Range. |
void |
setFormulaAsObject(java.lang.Object objFormula)
Sets the formula for this range. |
void |
setNoteText(java.lang.String strText)
Sets the noteText for the top-left cell of this range. |
void |
setRangeName(java.lang.String strName)
Sets the name of the Range to be accessed. |
void |
setRangeR1C1(int topRow,
int leftCol,
int bottomRow,
int rightCol)
This method can be used to identify the range to be accessed using the positions of the top-left and bottom-right cells |
void |
setValue(java.util.Vector objValue)
Sets the value property of this Range. |
void |
setValueAsObject(java.lang.Object objValue)
Sets the value for this range. |
void |
setWorksheetName(java.lang.String strName)
Sets the name of the worksheet to be accessed. |
void |
setWorksheetProtectionPassword(java.lang.String strPass)
Sets the worksheet protection password to be used while unprotecting the worksheet. |
void |
setXlWorkbook(ExcelWorkbook workbookBean)
Sets the reference to the ExcelWorkbook bean that this Range bean operates on. |
void |
unprotectWorksheet()
Unprotects the worksheet. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected transient java.beans.PropertyChangeSupport propertyChange
| Constructor Detail |
public ExcelRange()
| Method Detail |
public void addExcelRangeErrorListener(ExcelRangeErrorListener l)
l - The ExcelRangeErrorEvent listener.ExcelRangeErrorEvent,
ExcelRangeErrorListenerpublic void addExcelRangeListener(ExcelRangeListener l)
l - the ExcelRangeEvent listener.ExcelRangeEvent,
ExcelRangeListenerpublic void addExcelSheetListener(ExcelSheetListener l)
l - The ExcelSheetEvent listener.ExcelSheetEvent,
ExcelSheetListenerpublic void addFetchArgumentsListener(FetchArgumentsListener l)
l - The FetchArgumentsEvent listener.FetchArgumentsEvent,
FetchArgumentsListenerpublic void addFetchPasswordListener(FetchPasswordListener l)
l - The FetchPasswordEvent listener.FetchPasswordEvent,
FetchPasswordListenerpublic void addPropertyChangeListener(java.beans.PropertyChangeListener l)
l - The PropertyChangeEvent listener.PropertyChangeEvent,
PropertyChangeListenerpublic void clear()
public void clearContents()
public void clearFormats()
public void clearNotes()
public void createNamedRange(java.lang.String name)
name - The name to be assigned to this range.
public void fillExcelFormatModel()
throws ExcelAccessorException
ExcelAccessorException - Exception is thrown if
the ExcelRange bean itself is not in initialized state, or when an error occurs
while the bean accessing the workbook.
public void firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
public java.lang.String getAboutThisBean()
setAboutThisBean(java.lang.String)public boolean getAutoGetUsedRange()
setAutoGetUsedRange(boolean)public java.util.Vector getColumnHeaders()
public java.lang.String getDefaultText()
public int getEndCol()
public int getEndRow()
public ExcelFormatModel getExcelFormatModel()
setExcelFormatModel(com.ibm.excelaccessor.ExcelFormatModel)public java.lang.String getFormat()
public java.util.Vector getFormula()
public java.lang.Object getFormulaAsArray()
getFormulapublic int getNCols()
public java.lang.String getNoteText()
public int getNRows()
protected java.beans.PropertyChangeSupport getPropertyChange()
public java.lang.String getRangeName()
public java.util.Vector getRowHeaders()
public int getStartCol()
public int getStartRow()
public java.util.Vector getText()
getDefaultTextpublic java.util.Vector getValue()
public java.lang.Object getValueAsArray()
getValuepublic java.lang.String getWorksheetName()
public java.lang.Boolean hasArray()
null if the range is heterogeneous,
i.e. contains some cells that are part of an array.
False if no cells are part of an array.public java.lang.Boolean hasFormula()
null otherwise.public void initRange()
autoUnprotect is true it tries to
unprotect the sheet. If unprotection fails an error event is fired
and range initialization continues.
This method has to be called before this bean can be used in
a valid manner to access the properties of the range.
It fires rangeInitialized( ExcelRangeEvent ) on successful
initialization.
It fires ExcelRangeErrorEvent on failure.FetchArgumentsEvent,
ExcelRangeErrorEvent,
ExcelRangeEventpublic void insertWorksheet()
ExcelSheetEventpublic boolean isAutoCreateSheet()
autoCreateSheet property.public boolean isAutoUnprotectSheet()
autoUnprotectSheet property.public boolean isInitialized()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListenerevt - The PropertyChangeEvent.public void removeExcelRangeErrorListener(ExcelRangeErrorListener l)
l - The ExcelRangeErrorListener.ExcelRangeErrorEvent,
ExcelRangeErrorListenerpublic void removeExcelRangeListener(ExcelRangeListener l)
l - the ExcelRangeListener.ExcelRangeEvent,
ExcelRangeListenerpublic void removeExcelSheetListener(ExcelSheetListener l)
l - The ExcelSheetListener.ExcelSheetEvent,
ExcelSheetListenerpublic void removeFetchArgumentsListener(FetchArgumentsListener l)
l - The FetchArgumentsListener.FetchArgumentsEvent,
FetchArgumentsListenerpublic void removeFetchPasswordListener(FetchPasswordListener l)
l - the FetchPasswordListener.FetchPasswordEvent,
FetchPasswordListenerpublic void removePropertyChangeListener(java.beans.PropertyChangeListener l)
l - the PropertyChangeListener.PropertyChangeEvent,
PropertyChangeListenerpublic void removeWorksheet()
worksheetName. The range need not be
initialized to perform this operation. Before removing
the sheet, the FetchArgumentsEvent is fired which can be
used to set the worksheetName. During removal, if the
workbook structure is protected, it is
automatically unprotected. It fires sheetRemoved (ExcelSheetEvent)
on success. It fires ExcelRangeErrorEvent if an error occurs.ExcelSheetEvent
public void saveExcelFormatModel()
throws ExcelAccessorException
ExcelAccessorException - Exception is thrown if
the ExcelRange bean itself is not in initialized state, if the contained ExcelFormatModel
bean is not in initialized state, if the dimension of the ExcelFormatModel bean is not equals
to the dimension of the range - that is this.getExcelFormatModel().getRowCount() == this.getNRows()
and this.getExcelFormatModel().getColumnCount() == this.getNCols() -
or when an error occurs while the bean accessing the workbook.public void setAboutThisBean(java.lang.String aboutThisBean)
aboutThisBean - The new value for the property.getAboutThisBean()public void setAutoCreateSheet(boolean bValue)
bValue - The value to set.public void setAutoGetUsedRange(boolean autoGetUsedRange)
autoGetUsedRange - The new value for the property.getAutoGetUsedRange()public void setAutoUnprotectSheet(boolean bValue)
bValue - The value to set.
public void setCellR1C1(int row,
int col)
row - The row number of the cell.col - The column number of the cell.public void setExcelFormatModel(ExcelFormatModel excelFormatModel)
excelFormatModel - The new value for the property.getExcelFormatModel()public void setFormat(java.lang.String strFormat)
strFormat - String specifying the format.public void setFormula(java.util.Vector objFormula)
objFormula - A Vector of formulae for the cells.
In case the vector further contains vectors, all the
inner vectors should be of the same size. The inner Vectors
are taken to represent the rows of the range.public void setFormulaAsObject(java.lang.Object objFormula)
objFormula - The formula to be set.setFormulapublic void setNoteText(java.lang.String strText)
strText - String containing the noteText.public void setRangeName(java.lang.String strName)
strName - The name of the Range to be accessed.
public void setRangeR1C1(int topRow,
int leftCol,
int bottomRow,
int rightCol)
topRow - The row number of the top-left corner of
the range.leftCol - The column number of the top-left corner of
the range.bottomRow - The row number of the bottom right corner of
the range.rightCol - The column number of the bottom right corner of
the range.public void setValue(java.util.Vector objValue)
objValue - A Vector of values for the cells.
In case the vector further contains vectors, all the
inner vectors should be of the same size. The inner Vectors
are taken to represent the rows of the range.public void setValueAsObject(java.lang.Object objValue)
objValue - The value to be set.setValuepublic void setWorksheetName(java.lang.String strName)
strName - The name of the worksheet to be accessed.public void setWorksheetProtectionPassword(java.lang.String strPass)
strPass - The worksheet protection password.public void setXlWorkbook(ExcelWorkbook workbookBean)
workbookBean - The ExcelWorkbook on which all operations will
be performedpublic void unprotectWorksheet()
|
ExcelAccessor Bean Suite | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||