com.f1j.ss
Class SheetImpl

java.lang.Object
  |
  +--com.actuate.util.Debug
        |
        +--com.f1j.util.Debug
              |
              +--com.f1j.util.ObjConst
                    |
                    +--com.f1j.util.Obj
                          |
                          +--com.f1j.util.SharedHelper
                                |
                                +--com.f1j.util.SharedObj
                                      |
                                      +--com.f1j.util.SharedObjEx
                                            |
                                            +--com.f1j.ss.SheetImpl

public class SheetImpl
extends com.f1j.util.SharedObjEx
implements Sheet, Constants, com.f1j.util.ParseConstants

This class implements a worksheet contained in a Book.


Method Summary
 void addColPageBreak(int col)
          Adds a vertical page break to the left edge of the specified column.
 GRObject addGRObject(short objectType, double x1, double y1, double x2, double y2)
          Deprecated. Replaced by com.f1j.drawing.Drawing.addShape(com.f1j.drawing.EAutoShape, com.f1j.drawing.ClientAnchor).
 void addRowPageBreak(int row)
          Adds a horizontal page break to the top edge of the specified row.
 void clearRange(int row1, int col1, int row2, int col2, short clearType)
          Clears the specified range without checking for locked cells or partial clearing of array entered formulas.
 void copyDataFromArray(int row1, int col1, int row2, int col2, double[][] data)
          Copies data from an array into a sheet.
 void copyDataToArray(int row1, int col1, int row2, int col2, double[][] data)
          Copies data from the sheet into an array.
 void copyRange(int dstRow1, int dstCol1, int dstRow2, int dstCol2, Sheet srcSheet, int srcRow1, int srcCol1, int srcRow2, int srcCol2, short what)
          Copies a range of data from one worksheet to another.
 void editCopy(int nRow1, int nCol1, int nRow2, int nCol2)
          Copies the specified range to the clipboard.
 void editCut(int nRow1, int nCol1, int nRow2, int nCol2)
          Cuts the specified range to the clipboard.
 void editPaste(int nRow1, int nCol1, int nRow2, int nCol2, boolean bDone)
          Pastes data from the clipboard to the specified range.
 void editPasteSpecial(int nRow1, int nCol1, int nRow2, int nCol2, short what)
          Pastes data from the clipboard to the specified range.
 RangeRef getActiveRange()
          Returns the range of the worksheet that is occupied by data.
 RangeRef getArrayFormulaRange(int row, int col)
          Returns the array formula range of the specified cell.
 AutoFilter getAutoFilter()
          Returns the AutoFilter that is on this worksheet or null if there is no AutoFilter.
 Book getBook()
          Returns the workbook containing this worksheet.
 java.lang.String getCodeName()
          Returns the VBA object name of the worksheet.
 int getColOutlineLevel(int col)
          Returns the outline level of a single specified column.
 short getColOutlineType(int col)
          Returns the outline type of a single specified column.
 java.lang.String getColText(int col)
          Returns the label for a column.
 int getColWidth(int nCol)
          Returns the width of a single column.
 DataRange getDataRange(int index)
          Returns the DataRange at the specified index.
 DataRangeCollection getDataRangeCollection()
          Returns the DataRangeCollection for this sheet.
 int getDataRangeCount()
          Returns the number of DataRanges on this worksheet.
 int getDefaultColWidth()
          Returns the default column width.
 DataSet getDefaultDataSet()
          Returns the default DataSet for this sheet.
 int getDefaultRowHeight()
          Returns the default height for rows.
 Drawing getDrawing()
          Returns a reference to the drawing.
 java.lang.String getEntry(int row, int col)
          Returns the text value of the specified cell in the current worksheet in edit mode format.
 java.lang.String getEntry(java.lang.String location)
          Returns the value of the specified cell in edit mode format.
 GRObject getFirstGRObject()
          Deprecated.  
 java.lang.String getFormattedText(int row, int col)
          Returns the formatted text value of the specified cell.
 java.lang.String getFormula(int row, int col)
          Returns the text of the formula of the specified cell, in US English.
 GRObject getGRObject(int objectID)
          Deprecated. Replaced by com.f1j.drawing.Drawing.getShape(int).
 GRObject getGRObject(java.lang.String objectName)
          Deprecated.  
 int getHeaderHeight()
          Returns the height of the column headers.
 int getHeaderWidth()
          Returns the width of the row headers.
 short getHiddenState()
          Returns the hidden state for the sheet.
 java.lang.String getHyperlinkText(int nRow, int nCol)
          Retrieves the text of the hyperlink at the specified cell location.
 java.lang.String getHyperlinkToolTipText(int nRow, int nCol)
          Retrieves the hyperlink tool tip text for the specified cell location.
 int getHyperlinkType(int nRow, int nCol)
          Retrieves the type of the hyperlink at the specified cell location.
 int getLastCol()
          Returns the number of the last occupied column for this sheet.
 int getLastColForRow(int nRow)
          Returns the number of the last occupied column in the specified row.
 int getLastDataCol()
          Returns the number of the last occupied column for this sheet.
 int getLastDataColForRow(int nRow)
          Returns the number of the last occupied column in the specified row.
 int getLastDataRow()
          Returns the number of the last occupied row.
 int getLastRow()
          Returns the number of the last row that is not empty, including cells that contain only formatting.
 boolean getLogical(int row, int col)
          Returns the logical (true or false) value of the specified cell.
 java.lang.String getName()
          Returns the name of the worksheet.
 double getNumber(int row, int col)
          Returns the numeric value of the specified cell.
 PivotRange getPivotRange(int index)
          Returns the PivotRange at the specified index.
 int getPivotRangeCount()
          Returns the number of PivotRanges on this worksheet.
 int getProtectionFlags()
          Returns a set of flags indicating which actions are allowed when sheet protection is enabled.
 Range getRange(int row1, int col1, int row2, int col2)
          Returns a Range object for the specified coordinates.
 SheetProperties getReportFunctionsProperties()
          Returns the Report Functions properties associated with this sheet.
 int getRowHeight(int row)
          Returns the height of a single specified row.
 int getRowOutlineLevel(int row)
          Returns the outline level of a single specified row.
 short getRowOutlineType(int row)
          Returns the outline type of a single specified row.
 java.lang.String getRowText(int row)
          Returns the name of the specified row.
 int getSheetNumber()
          Returns the ordinal number of this worksheet within the workbook that contains it.
 short getSheetType()
          Returns the sheet type.
 java.lang.String getText(int row, int col)
          Returns the text value of the specified cell.
 java.lang.String getTopLeftText()
          Returns the text displayed at the intersection of the row and column headings in the top left corner.
 short getType(int row, int col)
          Returns the cell type of the specified cell.
 boolean hasAutoFilter()
          true if the AutoFilter drop-down arrows are currently displayed on the worksheet.
 boolean hasDrawing()
          Returns true if the sheet currently has a drawing.
 boolean isAllowed(int protectionFlags)
          Returns true if the sheet is not protected or if the sheet's current protection settings allow all of the specified actions.
 boolean isArrayFormula(int row, int col)
          Returns true if the specified cell is part of an array formula.
 boolean isEnableProtection()
          Deprecated. Replaced by #isProtected.
 boolean isFiltering()
          Indicates whether this worksheet is in filter mode.
 boolean isHyperlink(int nRow, int nCol)
          Returns true if the cell at the specified position contains a hyperlink.
 boolean isLotusEvaluation()
          Returns a flag indicating whether to evaluate formulas in a fashion compatible with Lotus 123.
 boolean isPasswordProtected()
          Returns true if protection is enabled with a password for this sheet.
 boolean isProtected()
          Returns true if protection is enabled for this sheet.
 boolean isRowHidden(int nRow)
          Returns true if the row is hidden.
 void removeGRObject(GRObject object)
          Deprecated. Replaced by com.f1j.drawing.Shape.delete().
 void setArrayFormula(int row1, int col1, int row2, int col2, java.lang.String formula)
          Sets the formula for the specified range to an array formula.
 void setCodeName(java.lang.String codeName)
          Assigns a VBA object name to this worksheet.
 void setColOutlineCollapsed(int col, boolean collapsed)
          Sets whether an outline group is collapsed or expanded.
 void setColOutlineLevel(int col1, int col2, int outlineLevel, boolean additive)
          Sets the outline level of a range of columns.
 void setColText(int col, java.lang.String colText)
          Sets the label for a column.
 void setDefaultDataSet(DataSet dataSet)
          Sets the default DataSet for this sheet.
 void setEnableProtection(boolean enableProtection)
          Deprecated. Replaced by setProtection(boolean, String, int).
 void setEnableProtection(boolean enableProtection, java.lang.String password)
          Deprecated. Replaced by setProtection(boolean, String, int).
 void setEntry(int row, int col, java.lang.String entry)
          Sets the value of a specified cell of all selected worksheets.
 void setEntry(java.lang.String location, java.lang.String entry)
          Sets the value of a specified cell.
 void setFormula(int row, int col, java.lang.String formula)
          Sets the formula for the specified cell.
 void setHiddenState(short hiddenState)
          Sets the hidden state for the sheet.
 void setLogical(int row, int col, boolean logical)
          Sets the logical (true or false) value of the specified cell.
 void setLotusEvaluation(boolean bLotusEvaluation)
          Sets a flag indicating whether to evaluate formulas in a fashion compatible with Lotus 123.
 void setName(java.lang.String sheetName)
          Assigns a name to this worksheet.
 void setNumber(int row, int col, double number)
          Sets the numeric value of the specified cell.
 void setProtection(boolean enableProtection, java.lang.String password, int flags)
          Sets whether protection is enabled for this sheet.
 void setReportFunctionsProperties(SheetProperties properties)
          Sets the Report Functions properties that should be associated with this sheet.
 void setRowOutlineCollapsed(int row, boolean collapsed)
          Sets whether an outline group is collapsed or expanded.
 void setRowOutlineLevel(int row1, int row2, int outlineLevel, boolean additive)
          Sets the outline level of a range of rows.
 void setRowText(int row, java.lang.String rowText)
          Sets the name for the specified row.
 void setSheetType(short sheetType)
          Sets the sheet type.
 void setText(int row, int col, java.lang.String text)
          Sets the value of the specified cell for all selected sheets.
 void setTopLeftText(java.lang.String topLeftText)
          Sets the text displayed at the intersection of the row and column headings in the top left corner of this worksheet.
 void showAllData()
          Makes all rows of the currently filtered list visible.
 void sort(int row1, int col1, int row2, int col2, boolean sortByRows, int[] keys)
          Specifies a range of data to sort and the keys by which to sort it.
 

Method Detail

addColPageBreak

public void addColPageBreak(int col)
Adds a vertical page break to the left edge of the specified column.
Parameters:
col - indicates the column where the page break is added.
Specified by:
addColPageBreak in interface Sheet
See Also:
addRowPageBreak(int)

addGRObject

public GRObject addGRObject(short objectType,
                            double x1,
                            double y1,
                            double x2,
                            double y2)
                     throws F1Exception
Deprecated. Replaced by com.f1j.drawing.Drawing.addShape(com.f1j.drawing.EAutoShape, com.f1j.drawing.ClientAnchor).
Creates and adds an object to the active worksheet.
Parameters:
objectType - identifies the type of object to be created.
x1 - coordinate of the first anchor point of the object. x1 is measured in columns from the left edge of the worksheet.
y1 - coordinate of the first anchor point of the object. y1 is measured in rows from the top edge of the worksheet.
x2 - coordinate of the second anchor point. x2 is measured in columns from the left edge of the worksheet.
y2 - coordinate of the second anchor point. y2 is measured in rows from the top edge of the worksheet.
Returns:
an object.
Throws:
F1Exception - if the object list is full.
Specified by:
addGRObject in interface Sheet

addRowPageBreak

public void addRowPageBreak(int row)
Adds a horizontal page break to the top edge of the specified row.
Parameters:
row - index number of the row where the page break is added. Rows are indexed from top to bottom beginning with 0
Specified by:
addRowPageBreak in interface Sheet

clearRange

public void clearRange(int row1,
                       int col1,
                       int row2,
                       int col2,
                       short clearType)
                throws AccessDeniedException,
                       DataConflictException,
                       F1Exception
Clears the specified range without checking for locked cells or partial clearing of array entered formulas.

Rows are indexed from top to bottom beginning with 0; sheets and columns are indexed from left to right beginning with 0.

Parameters:
row1 - Coordinate specifying the beginning row of the range.
col1 - Coordinate specifying the beginning column of the range.
row2 - Coordinate specifying the ending row of the range.
col2 - Coordinate specifying the ending column of the range.
clearType - Determines what is cleared, as follows:
  eClearFormats - clears formats only.
  eClearContents - clears values and formulas, including report range and pivot range content.
  eClearAll - clears all contents and formatting.
Throws:
F1Exception - if the object list is full.
Specified by:
clearRange in interface Sheet
See Also:
copyRange(int, int, int, int, com.f1j.ss.Sheet, int, int, int, int, short)

copyDataFromArray

public void copyDataFromArray(int row1,
                              int col1,
                              int row2,
                              int col2,
                              double[][] data)
                       throws F1Exception
Copies data from an array into a sheet.

The array and the sheet do not have to be the same size.

Rows are indexed from top to bottom beginning with 0; sheets and columns are indexed from left to right beginning with 0.

Parameters:
row1 - the coordinate specifying the beginning row to copy to.
col1 - the coordinate specifying the beginning column to copy to.
row2 - the coordinate of the ending row.
col2 - the coordinate of the ending column.
data - a 2-dimensional array to copy from.
Throws:
F1Exception - if a parameter is invalid.
Specified by:
copyDataFromArray in interface Sheet
See Also:
copyDataToArray(int, int, int, int, double[][])

copyDataToArray

public void copyDataToArray(int row1,
                            int col1,
                            int row2,
                            int col2,
                            double[][] data)
                     throws F1Exception
Copies data from the sheet into an array.

The array and the sheet range do not have to be the same size.

Rows are indexed from top to bottom beginning with 0; sheets and columns are indexed from left to right beginning with 0.

Parameters:
row1 - the coordinate of the beginning row.
col1 - the coordinate of the beginning column.
row2 - the coordinate of the ending row.
col2 - the coordinate of the ending column.
data - a 2-dimensional array to receive the data.
Throws:
F1Exception - if a parameter is invalid.
Specified by:
copyDataToArray in interface Sheet
See Also:
copyDataFromArray(int, int, int, int, double[][])

copyRange

public void copyRange(int dstRow1,
                      int dstCol1,
                      int dstRow2,
                      int dstCol2,
                      Sheet srcSheet,
                      int srcRow1,
                      int srcCol1,
                      int srcRow2,
                      int srcCol2,
                      short what)
               throws F1Exception
Copies a range of data from one worksheet to another.

this method allows you to choose the type of data to copy: formulas and data only, values only (w/o the formulas that created the value), formats only, or any combination of the previous types.

Rows are indexed from top to bottom beginning with 0; sheets and columns are indexed from left to right beginning with 0.

Note: this method does not check to see whether the workbook containing the source data needs to be recalculated. if you are copying values, not copying formulas from a range which may contain formulas, and not sure that the workbook containing this source range has been recalculated, you should call the checkRecalc method.

Parameters:
dstRow1 - the first row in the destination range.
dstCol1 - the first column in the destination range.
dstRow2 - the ending row in the destination range, inclusive.
dstCol2 - the ending column in the destination range, inclusive.
srcSheet - identifyies the source worksheet.
srcRow1 - the first row in the source range.
srcCol1 - the first column in the source range.
srcRow2 - the ending row in the source range, inclusive.
srcCol2 - the ending column in the source range, inclusive.
what - the type of copy operation, using one or more of the following constants:
    eCopyFormulas = 1
    eCopyValues   = 2
    eCopyFormats  = 4
    eCopyAll      = 7
Throws:
F1Exception - if a parameter is invalid.
Specified by:
copyRange in interface Sheet
See Also:
clearRange(int, int, int, int, short)

getActiveRange

public RangeRef getActiveRange()
Returns the range of the worksheet that is occupied by data.
Returns:
the occupied range of the worksheet.
Specified by:
getActiveRange in interface Sheet

getArrayFormulaRange

public RangeRef getArrayFormulaRange(int row,
                                     int col)
Returns the array formula range of the specified cell.
Parameters:
row - the row of the specified cell.
col - the column of the specified cell.
Returns:
the array formula range of the specified cell. Returns null if the cell does not contain an array formula.
Specified by:
getArrayFormulaRange in interface Sheet

getBook

public Book getBook()
Returns the workbook containing this worksheet.
Returns:
the Book this worksheet is in.
Specified by:
getBook in interface Sheet

getColOutlineLevel

public int getColOutlineLevel(int col)
Returns the outline level of a single specified column.
Parameters:
col - the column number.
Returns:
the outline level of the specified column.
Specified by:
getColOutlineLevel in interface Sheet
See Also:
getRowOutlineLevel(int), setColOutlineLevel(int, int, int, boolean), setRowOutlineLevel(int, int, int, boolean)

getColOutlineType

public short getColOutlineType(int col)
Returns the outline type of a single specified column.
Parameters:
col - the column number.
Returns:
the outline type of the specified column. this is either eOutlineTerminal, eOutlineExpanded or eOutlineCollapsed.
Specified by:
getColOutlineType in interface Sheet
See Also:
getColOutlineLevel(int), setColOutlineLevel(int, int, int, boolean), setColOutlineCollapsed(int, boolean)

getColText

public java.lang.String getColText(int col)
Returns the label for a column.
Parameters:
col - identifies a column by number.
Returns:
the column label text, or null if no column text has been set.
Specified by:
getColText in interface Sheet
See Also:
setColText(int, java.lang.String)

getColWidth

public int getColWidth(int nCol)
Returns the width of a single column.

Column width can be specified in units equal to 1/256th of the character 0's width in the default font, or in twips, depending on the column width units specified for the workbook.

Parameters:
col - identifies a column by number.
Returns:
the column width value.
Specified by:
getColWidth in interface Sheet
See Also:
BookModel.setColWidth(int, int, int, boolean)

getDefaultDataSet

public DataSet getDefaultDataSet()
Returns the default DataSet for this sheet. If a default DataSet has not been explicitly set for the sheet, then the default DataSet for the book is returned.
Returns:
the default DataSet for this sheet.
Specified by:
getDefaultDataSet in interface Sheet
Since:
12.0
See Also:
setDefaultDataSet(com.f1j.data.DataSet), DataSet

setDefaultDataSet

public void setDefaultDataSet(DataSet dataSet)
                       throws InvalidArgumentException
Sets the default DataSet for this sheet. Throws InvalidArgumentException if the specified DataSet is not defined within the book. Setting the default DataSet to null will result in the default being the default DataSet from the Book.
Parameters:
dataSet - The DataSet that should be used as the default for this sheet.
Throws:
InvalidArgumentException - if the specified DataSet does not exist in the book.
Specified by:
setDefaultDataSet in interface Sheet
Since:
12.0
See Also:
getDefaultDataSet(), DataSet

getDataRangeCollection

public DataRangeCollection getDataRangeCollection()
Returns the DataRangeCollection for this sheet.
Returns:
the data range collection for this sheet.
Specified by:
getDataRangeCollection in interface Sheet
See Also:
DataRangeCollection

getDefaultColWidth

public int getDefaultColWidth()
Returns the default column width.
Returns:
the default column width value.
Specified by:
getDefaultColWidth in interface Sheet

getDefaultRowHeight

public int getDefaultRowHeight()
Returns the default height for rows.
Returns:
the row height value in twips. A twip is 1/1440th of an inch.
Specified by:
getDefaultRowHeight in interface Sheet
See Also:
getRowHeight(int)

getDrawing

public Drawing getDrawing()

Returns a reference to the drawing.

if the sheet does not have a drawing, one is created. In some applications the automatic creation of a drawing may be undesirable because of memory footprint or file size concerns. if this is the case, call hasDrawing to determine whether the sheet has a drawing prior to calling this method.

Returns:
the drawing for this sheet.
Specified by:
getDrawing in interface Sheet
See Also:
hasDrawing()

hasDrawing

public boolean hasDrawing()

Returns true if the sheet currently has a drawing.

In applications where the presence of an empty drawing is considered undesirable because of memory footprint or file size concerns, this method should be called to see whether a drawing already exists in the sheet. this way the application can avoid a call to the getDrawing method, which would automatically create a drawing.

Returns:
true/false
Specified by:
hasDrawing in interface Sheet
See Also:
getDrawing()

getEntry

public java.lang.String getEntry(int row,
                                 int col)
Returns the text value of the specified cell in the current worksheet in edit mode format.

for example, if the cell contains a formula, the text of the formula is displayed. Returned formulas are preceded by an equal sign (=).

Note: The returned string is always in the user's language and should only be used for interaction with the user.

Parameters:
row - the row number.
col - the column number.
Returns:
a string containing the cell contents.
Specified by:
getEntry in interface Sheet
See Also:
setEntry(int, int, java.lang.String)

getEntry

public java.lang.String getEntry(java.lang.String location)
                          throws F1Exception
Returns the value of the specified cell in edit mode format.

for example, if the cell contains a formula, the text of the formula is returned. Returned formulas are preceded by an equal sign (=).

Note: The returned string is always in the user's language and should only be used for interaction with the user.

Parameters:
location - a defined name or a reference that identifies a cell.
Returns:
a string containing the cell contents.
Throws:
F1Exception - when an exception occurs.
Specified by:
getEntry in interface Sheet
See Also:
setEntry(int, int, java.lang.String)

getFirstGRObject

public GRObject getFirstGRObject()
Deprecated.  
Returns the first graphics object on a worksheet or null if there are none.
Returns:
the first graphics object on a worksheet or null if there are none.
Specified by:
getFirstGRObject in interface Sheet

getFormattedText

public java.lang.String getFormattedText(int row,
                                         int col)
                                  throws F1Exception
Returns the formatted text value of the specified cell.

this method returns the text as it is seen in the worksheet, including all formatting. To return unformatted text, use the getText or getEntry methods.

Parameters:
row - the row number of the cell from which the text is returned.
col - the column number of the cell from which the text is returned.
Returns:
a string containing the formatted text.
Throws:
F1Exception - when an exception occurs.
Specified by:
getFormattedText in interface Sheet
See Also:
getText(int, int), getEntry(int, int)

getFormula

public java.lang.String getFormula(int row,
                                   int col)
                            throws F1Exception
Returns the text of the formula of the specified cell, in US English.
Parameters:
row - the row number of the cell.
col - the column number of the cell.
Returns:
the formula of the specified cell.
Throws:
F1Exception - when an exception occurs.
Specified by:
getFormula in interface Sheet
See Also:
setFormula(int, int, java.lang.String)

getGRObject

public GRObject getGRObject(int objectID)
Deprecated. Replaced by com.f1j.drawing.Drawing.getShape(int).
Returns an object specified by its identification number.
Parameters:
objectID - the object's identification number.
Returns:
the specified object or null if no object is found.
Specified by:
getGRObject in interface Sheet
See Also:
addGRObject(short, double, double, double, double), removeGRObject(com.f1j.ss.GRObject)

getGRObject

public GRObject getGRObject(java.lang.String objectName)
Deprecated.  
Returns an object specified by name.
Parameters:
objectName - the name of the object.
Returns:
the specified object or null if no object is found.
Specified by:
getGRObject in interface Sheet
See Also:
addGRObject(short, double, double, double, double), removeGRObject(com.f1j.ss.GRObject)

getHiddenState

public short getHiddenState()
Returns the hidden state for the sheet.
Returns:
the hidden state for the sheet:
Hidden State Flags
Tag Description
eSheetShown show the sheet.
eSheetHidden hide the sheet.
eSheetVeryHidden hide the sheet and disable the ability to reshow the sheet with the GUI.
Specified by:
getHiddenState in interface Sheet
See Also:
setHiddenState(short)

getLastCol

public int getLastCol()
Returns the number of the last occupied column for this sheet.

this method returns the last column that is not empty, including cells that contain only formatting.

Returns:
the last occupied column.
Specified by:
getLastCol in interface Sheet
See Also:
getLastColForRow(int), getLastDataCol(), getLastDataRow(), getLastDataColForRow(int), getLastRow()

getLastColForRow

public int getLastColForRow(int nRow)
Returns the number of the last occupied column in the specified row.

this method returns the last column that is not empty, including cells that contain only formatting. -1 is returned for a row with no cells.

Parameters:
row - the specified row.
Returns:
the last occupied column in the row or -1 for an empty row.
Specified by:
getLastColForRow in interface Sheet
See Also:
getLastCol(), getLastDataCol(), getLastDataRow(), getLastDataColForRow(int), getLastRow()

getLastRow

public int getLastRow()
Returns the number of the last row that is not empty, including cells that contain only formatting. The value -1 is returned if the sheet contains no cells.
Returns:
the number of the last row.
Specified by:
getLastRow in interface Sheet
See Also:
getLastCol(), getLastColForRow(int), getLastDataCol(), getLastDataRow(), getLastDataColForRow(int)

getLastDataCol

public int getLastDataCol()
Returns the number of the last occupied column for this sheet.

this method returns the last column that contains data, ignoring cells that contain only formatting. -1 is returned for a row with no data cells.

Returns:
the last occupied column.
Specified by:
getLastDataCol in interface Sheet
See Also:
getLastCol(), getLastColForRow(int), getLastDataRow(), getLastDataColForRow(int), getLastRow()

getLastDataColForRow

public int getLastDataColForRow(int nRow)
Returns the number of the last occupied column in the specified row.

this method returns the last column that contains data, ignoring cells that contain only formatting. -1 is returned for a row with no data cells.

Parameters:
row - the specified row.
Returns:
the last occupied column in the row or -1 for an empty row.
Specified by:
getLastDataColForRow in interface Sheet
See Also:
getLastCol(), getLastColForRow(int), getLastDataCol(), getLastDataRow(), getLastRow()

getLastDataRow

public int getLastDataRow()
Returns the number of the last occupied row.

this method returns the last row that contains data, ignoring cells that contain only formatting. -1 is returned if the sheet contains no data cells.

Returns:
the number of the last row.
Specified by:
getLastDataRow in interface Sheet
See Also:
getLastCol(), getLastColForRow(int), getLastDataCol(), getLastDataColForRow(int), getLastRow()

getLogical

public boolean getLogical(int row,
                          int col)
                   throws F1Exception
Returns the logical (true or false) value of the specified cell.

if the cell contains a number, its logical value is true for non-zero values, and false for zero values. if the cell has text that can be converted to a number, the text is converted and treated as a numeric cell. if the cell contains a formula, the above rules apply depending on the formula's result. All other cells, including empty cells, have a false logical value.

Parameters:
row - identifies the row by number.
col - identifies the column by number.
Returns:
true/false.
Throws:
F1Exception - when an exception occurs.
Specified by:
getLogical in interface Sheet
See Also:
setLogical(int, int, boolean)

getName

public java.lang.String getName()
Returns the name of the worksheet.
Returns:
the name of the worksheet.
Specified by:
getName in interface Sheet
See Also:
setName(java.lang.String), getCodeName()

getCodeName

public java.lang.String getCodeName()
Returns the VBA object name of the worksheet.
Returns:
the VBA object name of the worksheet.
Specified by:
getCodeName in interface Sheet
Since:
11.0.1
See Also:
setCodeName(java.lang.String), getName()

getNumber

public double getNumber(int row,
                        int col)
Returns the numeric value of the specified cell.

Cells containing a formula return the numeric result of the formula. if a cell contains text, an attempt is made to convert the text to a number. if the text cannot be converted, 0 (No Error) is returned.

Parameters:
row - the row coordinate.
col - the column coordinate.
Returns:
the numeric value of the specified cell.
Specified by:
getNumber in interface Sheet
See Also:
setNumber(int, int, double)

getProtectionFlags

public int getProtectionFlags()
Returns a set of flags indicating which actions are allowed when sheet protection is enabled.
Returns:
kAllowNone if nothing is allowed, or one or more of the following flags:
 kAllowDefault
 kAllowEditObjects
 kAllowFormatCells
 kAllowFormatColumns
 kAllowFormatRows
 kAllowInsertColumns
 kAllowInsertRows
 kAllowInsertHyperlinks
 kAllowDeleteColumns
 kAllowDeleteRows
 kAllowSelectLocked
 kAllowSort
 kAllowUseAutoFilter
 kAllowUsePivotRanges
 kAllowSelectUnlocked
 
Specified by:
getProtectionFlags in interface Sheet
See Also:
isProtected(), isPasswordProtected(), setProtection(boolean, java.lang.String, int), isAllowed(int), BookModel.getSheetProtectionFlags(int), Book.getProtectionFlags()

getRowHeight

public int getRowHeight(int row)
Returns the height of a single specified row.
Parameters:
row - the row number.
Returns:
the row height in twips. A twip is 1/1440th of an inch.
Specified by:
getRowHeight in interface Sheet
See Also:
getDefaultRowHeight()

getRowOutlineLevel

public int getRowOutlineLevel(int row)
Returns the outline level of a single specified row.
Parameters:
row - the row number.
Returns:
the outline level of the specified row.
Specified by:
getRowOutlineLevel in interface Sheet
See Also:
getColOutlineLevel(int), setColOutlineLevel(int, int, int, boolean), setRowOutlineLevel(int, int, int, boolean)

getRowOutlineType

public short getRowOutlineType(int row)
Returns the outline type of a single specified row.
Parameters:
row - the row number.
Returns:
the outline type of the specified row. this is either eOutlineTerminal, eOutlineExpanded or eOutlineCollapsed.
Specified by:
getRowOutlineType in interface Sheet
See Also:
getRowOutlineLevel(int), setRowOutlineLevel(int, int, int, boolean), setRowOutlineCollapsed(int, boolean)

getRowText

public java.lang.String getRowText(int row)
Returns the name of the specified row.

Naming a row is useful for providing labels that reflect the data in the row. The row name is displayed in the row heading is used for display purposes only. The row is still referred to by normal cell references in formulas. Row names can be up to 254 characters long.

Parameters:
row - the row number.
Returns:
a string containing the row name.
Specified by:
getRowText in interface Sheet
See Also:
setRowText(int, java.lang.String)

getSheetNumber

public int getSheetNumber()
Returns the ordinal number of this worksheet within the workbook that contains it.
Returns:
the ordinal number of this worksheet within the workbook that contains it.
Specified by:
getSheetNumber in interface Sheet

getSheetType

public short getSheetType()
Returns the sheet type.
Returns:
one of the following sheet types:
          eSheetTypeSheet
          eSheetTypeChart
Specified by:
getSheetType in interface Sheet
See Also:
setSheetType(short)

setHiddenState

public void setHiddenState(short hiddenState)
                    throws F1Exception
Sets the hidden state for the sheet.
Parameters:
hiddenState - one of the following flags indicating the desired hidden state:
Hidden State Flags
Tag Description
eSheetShown show the sheet.
eSheetHidden hide the sheet.
eSheetVeryHidden hide the sheet and disable the ability to reshow the sheet with the GUI.
Throws:
F1Exception - if this call would hide the last visible sheet or if the book is protected.
Specified by:
setHiddenState in interface Sheet
See Also:
getHiddenState()

getText

public java.lang.String getText(int row,
                                int col)
Returns the text value of the specified cell.
Parameters:
row - identifies the cell row by number.
col - identifies the cell column by number.
Returns:
the text value of the specified cell.
Specified by:
getText in interface Sheet
See Also:
setText(int, int, java.lang.String)

getTopLeftText

public java.lang.String getTopLeftText()
Returns the text displayed at the intersection of the row and column headings in the top left corner.
Returns:
the top left corner text.
Specified by:
getTopLeftText in interface Sheet
See Also:
setTopLeftText(java.lang.String)

getType

public short getType(int row,
                     int col)
Returns the cell type of the specified cell.
Parameters:
row - identifies the cell row by number.
col - identifies the cell column by number.
Returns:
one of the following cell types:
       com.f1j.ss.Book.eTypeEmpty
       com.f1j.ss.Book.eTypeNumber
       com.f1j.ss.Book.eTypeText
       com.f1j.ss.Book.eTypeLogical
       com.f1j.ss.Book.eTypeError
 
A negative value indicates that the cell contains a formula.
Specified by:
getType in interface Sheet
See Also:
Selection.setType(short), ConditionalFormat.setType(short)

isAllowed

public boolean isAllowed(int protectionFlags)
Returns true if the sheet is not protected or if the sheet's current protection settings allow all of the specified actions.
Parameters:
protectionFlags - One or more of the following flags:
 kAllowDefault
 kAllowEditObjects
 kAllowFormatCells
 kAllowFormatColumns
 kAllowFormatRows
 kAllowInsertColumns
 kAllowInsertRows
 kAllowInsertHyperlinks
 kAllowDeleteColumns
 kAllowDeleteRows
 kAllowSelectLocked
 kAllowSort
 kAllowUseAutoFilter
 kAllowUsePivotRanges
 kAllowSelectUnlocked
 
Returns:
boolean. true/false.
Specified by:
isAllowed in interface Sheet
See Also:
getProtectionFlags(), setProtection(boolean, java.lang.String, int), isProtected(), isPasswordProtected(), BookModel.isAllowedSheetAction(int), Book.isProhibited(int)

isArrayFormula

public boolean isArrayFormula(int row,
                              int col)
Returns true if the specified cell is part of an array formula.
Parameters:
row - specifies the row of the cell.
col - specifies the column of the cell.
Returns:
true if the specified cell is part of an array formula.
Specified by:
isArrayFormula in interface Sheet
See Also:
getArrayFormulaRange(int, int), getFormula(int, int)

isEnableProtection

public boolean isEnableProtection()
Deprecated. Replaced by #isProtected.
Returns true if protection is enabled for this sheet.

Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.

Returns:
boolean. true/false.
Specified by:
isEnableProtection in interface Sheet
See Also:
isPasswordProtected(), setEnableProtection(boolean)

isProtected

public boolean isProtected()
Returns true if protection is enabled for this sheet.

Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.

Returns:
boolean. true/false.
Specified by:
isProtected in interface Sheet
See Also:
isPasswordProtected(), setProtection(boolean, java.lang.String, int), getProtectionFlags(), isAllowed(int), BookModel.isSheetProtected(int), Book.isProtected()

isPasswordProtected

public boolean isPasswordProtected()
Returns true if protection is enabled with a password for this sheet. this method returns false if protection is enabled without a password. Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.
Returns:
boolean. true/false.
Specified by:
isPasswordProtected in interface Sheet
See Also:
isProtected(), setProtection(boolean, java.lang.String, int), getProtectionFlags(), isAllowed(int), BookModel.isSheetPasswordProtected(int), Book.isPasswordProtected()

isLotusEvaluation

public boolean isLotusEvaluation()
Returns a flag indicating whether to evaluate formulas in a fashion compatible with Lotus 123.
Returns:
the flag indicating whether to evaluate formulas in a fashion compatible with Lotus 123.
Specified by:
isLotusEvaluation in interface Sheet
See Also:
setLotusEvaluation(boolean)

removeGRObject

public void removeGRObject(GRObject object)
                    throws F1Exception
Deprecated. Replaced by com.f1j.drawing.Shape.delete().
Removes the specified object.
Parameters:
object - the GRObject to remove.
Throws:
F1Exception - if the object is not found.
Specified by:
removeGRObject in interface Sheet
See Also:
addGRObject(short, double, double, double, double)

setArrayFormula

public void setArrayFormula(int row1,
                            int col1,
                            int row2,
                            int col2,
                            java.lang.String formula)
                     throws F1Exception
Sets the formula for the specified range to an array formula.
Parameters:
row1 - the first row in the range.
col1 - the first column in the range.
row2 - the last row in the range.
col2 - the last column in the range.
formula - formula for the specified cell. The string should not have a leading equal sign (=).
Throws:
F1Exception - if the string is not a valid formula.
Specified by:
setArrayFormula in interface Sheet
See Also:
getFormula(int, int), getArrayFormulaRange(int, int)

setColOutlineLevel

public void setColOutlineLevel(int col1,
                               int col2,
                               int outlineLevel,
                               boolean additive)
                        throws F1Exception
Sets the outline level of a range of columns.
Parameters:
col1 - the first column in the range.
col2 - the last column in the range.
outlineLevel - the outline level to set. The outline level may be set from zero to seven.
additive - boolean. Specifies whether the outline level is an absolute value to set or should be added to the current outline level. true = the value specified in the outlineLevel parameter is added to the current outline level of each column. false = the outline level of the specified columns is set to the value specified in the outlineLevel parameter.
Throws:
F1Exception - if the object list is full.
Specified by:
setColOutlineLevel in interface Sheet
See Also:
getColOutlineLevel(int), getRowOutlineLevel(int), setRowOutlineLevel(int, int, int, boolean)

setColOutlineCollapsed

public void setColOutlineCollapsed(int col,
                                   boolean collapsed)
                            throws F1Exception
Sets whether an outline group is collapsed or expanded.
Parameters:
col - the column to expand or collapse. The column must currently have an outline type of eOutlineCollapsed or eOutlineExpanded.
collapsed - boolean. true = collapse the outline group. false = expand the outline group.
Throws:
F1Exception - if the object list is full.
Specified by:
setColOutlineCollapsed in interface Sheet
See Also:
getColOutlineLevel(int), setColOutlineLevel(int, int, int, boolean), getColOutlineType(int)

setColText

public void setColText(int col,
                       java.lang.String colText)
                throws F1Exception
Sets the label for a column.

Naming a column is useful for labeling columns so they reflect the data in the column (e.g., column G might be named Total Sales). The column name is displayed in the column heading and is used for display purposes only. The column is still referred to by letter reference in formulas. The column name can be up to 9 lines and 254 bytes. A CR (carriage return) and LF (line feed) combination are counted as two characters.

Parameters:
col - identifies a column by number.
colText - the column label text.
Specified by:
setColText in interface Sheet
See Also:
getColText(int)

setEnableProtection

public void setEnableProtection(boolean enableProtection)
Deprecated. Replaced by setProtection(boolean, String, int).
Sets whether protection is enabled for this sheet.

Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.

Parameters:
enableProtection - boolean. Indicates whether protection is to be enabled.
Throws:
java.lang.reflect.UndeclaredThrowableException - if the sheet is protected with a password. The setProtection(boolean, String, int) method allows you to specify a password.
Specified by:
setEnableProtection in interface Sheet
See Also:
isEnableProtection(), isPasswordProtected()

setEnableProtection

public void setEnableProtection(boolean enableProtection,
                                java.lang.String password)
                         throws F1Exception
Deprecated. Replaced by setProtection(boolean, String, int).
Sets whether protection is enabled for this sheet.

Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.

Parameters:
enableProtection - boolean. Indicates whether protection is to be enabled.
password - The protection password. this may be null if no password is to be used.
Throws:
F1Exception - if password is invalid
Specified by:
setEnableProtection in interface Sheet
See Also:
isEnableProtection(), isPasswordProtected()

setProtection

public void setProtection(boolean enableProtection,
                          java.lang.String password,
                          int flags)
                   throws AccessDeniedException,
                          InvalidArgumentException,
                          ReportPreviewException
Sets whether protection is enabled for this sheet.

Enabling protection means that any cells marked as hidden or locked are actually hidden and locked.

Parameters:
enableProtection - boolean. Indicates whether protection is to be enabled.
password - The protection password. this may be null if no password is to be used.
flags - kAllowNone if nothing should be allowed, or one or more of the following:
 kAllowDefault
 kAllowEditObjects
 kAllowFormatCells
 kAllowFormatColumns
 kAllowFormatRows
 kAllowInsertColumns
 kAllowInsertRows
 kAllowInsertHyperlinks
 kAllowDeleteColumns
 kAllowDeleteRows
 kAllowSelectLocked
 kAllowSort
 kAllowUseAutoFilter
 kAllowUsePivotRanges
 kAllowSelectUnlocked
 
Throws:
AccessDeniedException - if the sheet is protected.
InvalidArgumentException - if the flags are invalid.
ReportPreviewException - if protection cannot be changed because the book is in Report Range preview mode.
F1Exception - if an error occurs.
Specified by:
setProtection in interface Sheet
Since:
11.0
See Also:
isProtected(), isPasswordProtected(), getProtectionFlags(), isAllowed(int), BookModel.setSheetProtection(int, boolean, java.lang.String, int), Book.setProtection(boolean, java.lang.String, int)

setEntry

public void setEntry(int row,
                     int col,
                     java.lang.String entry)
              throws F1Exception
Sets the value of a specified cell of all selected worksheets.

this method allows you to enter information in a cell just as a user would enter information. e.Spreadsheet automatically determines the kind of data entered (e.g., number, text, formula). e.Spreadsheet also recognizes dates, times, percentages, currency, fractions, and scientific notation and applies an appropriate number format. When setting formulas, precede the formula with an equal sign (=).

Note this value is always in the user's language and should only be used to interact with the user.

Parameters:
row - a row number that identifies a cell.
col - a column number that identifies a cell.
entry - a cell value.
Throws:
F1Exception - when an exception occurs.
Specified by:
setEntry in interface Sheet
See Also:
getEntry(int, int)

setEntry

public void setEntry(java.lang.String location,
                     java.lang.String entry)
              throws F1Exception
Sets the value of a specified cell.

this method allows you to enter information in a cell just as a user would enter information. e.Spreadsheet automatically determines the kind of data entered (e.g., number, text, formula). e.Spreadsheet also recognizes dates, times, percentages, currency, fractions, and scientific notation and applies an appropriate number format. When setting formulas, precede the formula with an equal sign (=).

Note this value is always in the user's language and should only be used to interact with the user.

Parameters:
location - a defined name or a reference that identifies a cell.
entry - a cell value.
Throws:
F1Exception - when an exception occurs.
Specified by:
setEntry in interface Sheet
See Also:
getEntry(int, int)

setFormula

public void setFormula(int row,
                       int col,
                       java.lang.String formula)
                throws F1Exception
Sets the formula for the specified cell.
Parameters:
row - number of a row that identifies a specific cell.
col - number of a column that identifies a specific cell.
formula - formula for the specified cell. The string should not have a leading equal sign (=).
Throws:
F1Exception - if the string is not a valid formula.
Specified by:
setFormula in interface Sheet
See Also:
getFormula(int, int)

setLogical

public void setLogical(int row,
                       int col,
                       boolean logical)
                throws F1Exception
Sets the logical (true or false) value of the specified cell.
Parameters:
row - number of a row that identifies a specific cell.
col - number of a column that identifies a specific cell.
logical - boolean. The logical value for the cell.
Throws:
F1Exception - when an exception occurs.
Specified by:
setLogical in interface Sheet
See Also:
getLogical(int, int)

setLotusEvaluation

public void setLotusEvaluation(boolean bLotusEvaluation)
Sets a flag indicating whether to evaluate formulas in a fashion compatible with Lotus 123.
Parameters:
lotusEvaluation - boolean. true = evaluate formulas like Lotus 123. When formulas are evaluated like Lotus 123, logical formulas return zero instead of FALSE and one instead of TRUE. Also, strings are treated as zero instead of being converted to their numeric value or #VALUE!.
Specified by:
setLotusEvaluation in interface Sheet
See Also:
isLotusEvaluation()

setNumber

public void setNumber(int row,
                      int col,
                      double number)
               throws AccessDeniedException,
                      DataConflictException,
                      F1Exception
Sets the numeric value of the specified cell.
Parameters:
row - the number of a row that identifies a specific cell.
col - the number of a column that identifies a specific cell.
number - the cell value.
Throws:
F1Exception - if row or column numbers are not valid.
Specified by:
setNumber in interface Sheet
See Also:
getNumber(int, int)

setRowOutlineLevel

public void setRowOutlineLevel(int row1,
                               int row2,
                               int outlineLevel,
                               boolean additive)
                        throws F1Exception
Sets the outline level of a range of rows.
Parameters:
row1 - the first row in the range.
row2 - the last row in the range.
outlineLevel - the outline level to set. The outline level may be set from zero to seven.
additive - boolean. Specifies whether the outline level is an absolute value to set or should be added to the current outline level. true = the value specified in the outlineLevel parameter is added to the current outline level of each column. false = the outline level of the specified columns is set to the value specified in the outlineLevel parameter.
Throws:
F1Exception - if the object list is full.
Specified by:
setRowOutlineLevel in interface Sheet
See Also:
getColOutlineLevel(int), getRowOutlineLevel(int), setColOutlineLevel(int, int, int, boolean)

setRowOutlineCollapsed

public void setRowOutlineCollapsed(int row,
                                   boolean collapsed)
                            throws F1Exception
Sets whether an outline group is collapsed or expanded.
Parameters:
row - the row to expand or collapse. The row must currently have an outline type of eOutlineCollapsed or eOutlineExpanded.
collapsed - boolean. true = collapse the outline group. false expand the outline group.
Throws:
F1Exception - if the object list is full.
Specified by:
setRowOutlineCollapsed in interface Sheet
See Also:
getRowOutlineLevel(int)