Home » POI-3.5 » org.apache » poi » hssf » usermodel » [javadoc | source]
org.apache.poi.hssf.usermodel
public final class: HSSFSheet [javadoc | source]
java.lang.Object
   org.apache.poi.hssf.usermodel.HSSFSheet

All Implemented Interfaces:
    Sheet

High level representation of a worksheet.
Field Summary
public static final  int INITIAL_CAPACITY    Used for compile-time optimization. This is the initial size for the collection of rows. It is currently set to 20. If you generate larger sheets you may benefit by setting this to a higher number and recompiling a custom edition of HSSFSheet. 
protected final  Workbook _book     
protected final  HSSFWorkbook _workbook     
Constructor:
 protected HSSFSheet(HSSFWorkbook workbook) 
    Creates new HSSFSheet - called by HSSFWorkbook to create a sheet from scratch. You should not be calling this from application code (its protected anyhow).
    Parameters:
    workbook - - The HSSF Workbook object associated with the sheet.
    Also see:
    org.apache.poi.hssf.usermodel.HSSFWorkbook#createSheet()
 protected HSSFSheet(HSSFWorkbook workbook,
    Sheet sheet) 
    Creates an HSSFSheet representing the given Sheet object. Should only be called by HSSFWorkbook when reading in an exisiting file.
    Parameters:
    workbook - - The HSSF Workbook object associated with the sheet.
    sheet - - lowlevel Sheet object this sheet will represent
    Also see:
    org.apache.poi.hssf.usermodel.HSSFWorkbook#createSheet()
Method from org.apache.poi.hssf.usermodel.HSSFSheet Summary:
addMergedRegion,   addMergedRegion,   addValidationData,   autoSizeColumn,   autoSizeColumn,   cloneSheet,   createDrawingPatriarch,   createFreezePane,   createFreezePane,   createRow,   createSplitPane,   dumpDrawingRecords,   getAlternateExpression,   getAlternateFormula,   getAutobreaks,   getCellComment,   getColumnBreaks,   getColumnStyle,   getColumnWidth,   getColumnWidth,   getDefaultColumnWidth,   getDefaultRowHeight,   getDefaultRowHeightInPoints,   getDialog,   getDisplayGuts,   getDrawingEscherAggregate,   getDrawingPatriarch,   getFirstRowNum,   getFitToPage,   getFooter,   getForceFormulaRecalculation,   getHeader,   getHorizontallyCenter,   getLastRowNum,   getLeftCol,   getMargin,   getMergedRegion,   getMergedRegionAt,   getNumMergedRegions,   getObjectProtect,   getPaneInformation,   getPassword,   getPhysicalNumberOfRows,   getPrintSetup,   getProtect,   getRow,   getRowBreaks,   getRowSumsBelow,   getRowSumsRight,   getScenarioProtect,   getSheet,   getSheetConditionalFormatting,   getSheetName,   getTopRow,   getVerticallyCenter,   getVerticallyCenter,   getWorkbook,   groupColumn,   groupColumn,   groupRow,   insertChartRecords,   isActive,   isColumnBroken,   isColumnHidden,   isColumnHidden,   isDisplayFormulas,   isDisplayGridlines,   isDisplayRowColHeadings,   isDisplayZeros,   isGridsPrinted,   isPrintGridlines,   isRowBroken,   isSelected,   iterator,   protectSheet,   removeColumnBreak,   removeMergedRegion,   removeRow,   removeRowBreak,   rowIterator,   setActive,   setAlternativeExpression,   setAlternativeFormula,   setAutobreaks,   setColumnBreak,   setColumnGroupCollapsed,   setColumnGroupCollapsed,   setColumnHidden,   setColumnHidden,   setColumnWidth,   setColumnWidth,   setDefaultColumnStyle,   setDefaultColumnWidth,   setDefaultColumnWidth,   setDefaultRowHeight,   setDefaultRowHeightInPoints,   setDialog,   setDisplayFormulas,   setDisplayGridlines,   setDisplayGuts,   setDisplayRowColHeadings,   setDisplayZeros,   setFitToPage,   setForceFormulaRecalculation,   setGridsPrinted,   setHorizontallyCenter,   setMargin,   setPrintGridlines,   setRowBreak,   setRowGroupCollapsed,   setRowSumsBelow,   setRowSumsRight,   setSelected,   setVerticallyCenter,   setZoom,   shiftMerged,   shiftRows,   shiftRows,   shiftRows,   showInPane,   ungroupColumn,   ungroupColumn,   ungroupRow,   validateColumn,   validateRow
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.poi.hssf.usermodel.HSSFSheet Detail:
 public int addMergedRegion(Region region) 
Deprecated! ( - Aug-2008) use CellRangeAddress instead of Region

 public int addMergedRegion(CellRangeAddress region) 
    adds a merged region of cells (hence those cells form one)
 public  void addValidationData(HSSFDataValidation dataValidation) 
    Creates a data validation object
 public  void autoSizeColumn(int column) 
    Adjusts the column width to fit the contents. This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing.
 public  void autoSizeColumn(int column,
    boolean useMergedCells) 
    Adjusts the column width to fit the contents. This process can be relatively slow on large sheets, so this should normally only be called once per column, at the end of your processing. You can specify whether the content of merged cells should be considered or ignored. Default is to ignore merged cells.
 HSSFSheet cloneSheet(HSSFWorkbook workbook) 
 public HSSFPatriarch createDrawingPatriarch() 
    Creates the top-level drawing patriarch. This will have the effect of removing any existing drawings on this sheet. This may then be used to add graphics or charts
 public  void createFreezePane(int colSplit,
    int rowSplit) 
    Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
 public  void createFreezePane(int colSplit,
    int rowSplit,
    int leftmostColumn,
    int topRow) 
    Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
 public HSSFRow createRow(int rownum) 
    Create a new row within the sheet and return the high level representation
 public  void createSplitPane(int xSplitPos,
    int ySplitPos,
    int leftmostColumn,
    int topRow,
    int activePane) 
    Creates a split pane. Any existing freezepane or split pane is overwritten.
 public  void dumpDrawingRecords(boolean fat) 
    Aggregates the drawing records and dumps the escher record hierarchy to the standard output.
 public boolean getAlternateExpression() 
    whether alternate expression evaluation is on
 public boolean getAlternateFormula() 
    whether alternative formula entry is on
 public boolean getAutobreaks() 
    show automatic page breaks or not
 public HSSFComment getCellComment(int row,
    int column) 
    Returns cell comment for the specified row and column
 public int[] getColumnBreaks() 
 public HSSFCellStyle getColumnStyle(int column) 
    Returns the HSSFCellStyle that applies to the given (0 based) column, or null if no style has been set for that column
 public short getColumnWidth(short columnIndex) 
Deprecated! ( - Sep 2008) use #getColumnWidth(int)

 public int getColumnWidth(int columnIndex) 
    get the width (in units of 1/256th of a character width )
 public int getDefaultColumnWidth() 
    get the default column width for the sheet (if the columns do not define their own width) in characters
 public short getDefaultRowHeight() 
    get the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
 public float getDefaultRowHeightInPoints() 
    get the default row height for the sheet (if the rows do not define their own height) in points.
 public boolean getDialog() 
    get whether sheet is a dialog sheet or not
 public boolean getDisplayGuts() 
    get whether to display the guts or not
 public EscherAggregate getDrawingEscherAggregate() 
    Returns the agregate escher records for this sheet, it there is one. WARNING - calling this will trigger a parsing of the associated escher records. Any that aren't supported (such as charts and complex drawing types) will almost certainly be lost or corrupted when written out.
 public HSSFPatriarch getDrawingPatriarch() 
    Returns the top-level drawing patriach, if there is one. This will hold any graphics or charts for the sheet. WARNING - calling this will trigger a parsing of the associated escher records. Any that aren't supported (such as charts and complex drawing types) will almost certainly be lost or corrupted when written out. Only use this with simple drawings, otherwise call HSSFSheet#createDrawingPatriarch() and start from scratch!
 public int getFirstRowNum() 
    Gets the first row on the sheet
 public boolean getFitToPage() 
    fit to page option is on
 public HSSFFooter getFooter() 
 public boolean getForceFormulaRecalculation() 
    Whether a record must be inserted or not at generation to indicate that formula must be recalculated when workbook is opened.
 public HSSFHeader getHeader() 
 public boolean getHorizontallyCenter() 
    Determine whether printed output for this sheet will be horizontally centered.
 public int getLastRowNum() 
    Gets the number last row on the sheet. Owing to idiosyncrasies in the excel file format, if the result of calling this method is zero, you can't tell if that means there are zero rows on the sheet, or one at position zero. For that case, additionally call #getPhysicalNumberOfRows() to tell if there is a row at position zero or not.
 public short getLeftCol() 
    The left col in the visible view when the sheet is first viewed after opening it in a viewer
 public double getMargin(short margin) 
    Gets the size of the margin in inches.
 public CellRangeAddress getMergedRegion(int index) 
 public Region getMergedRegionAt(int index) 
Deprecated! ( - Aug-2008) use HSSFSheet#getMergedRegion(int)

 public int getNumMergedRegions() 
    returns the number of merged regions
 public boolean getObjectProtect() 
    Answer whether object protection is enabled or disabled
 public PaneInformation getPaneInformation() 
    Returns the information regarding the currently configured pane (split or freeze).
 public short getPassword() 
 public int getPhysicalNumberOfRows() 
    Returns the number of physically defined rows (NOT the number of rows in the sheet)
 public HSSFPrintSetup getPrintSetup() 
    Gets the print setup object.
 public boolean getProtect() 
    Answer whether protection is enabled or disabled
 public HSSFRow getRow(int rowIndex) 
    Returns the logical row (not physical) 0-based. If you ask for a row that is not defined you get a null. This is to say row 4 represents the fifth row on a sheet.
 public int[] getRowBreaks() 
 public boolean getRowSumsBelow() 
    get if row summaries appear below detail in the outline
 public boolean getRowSumsRight() 
    get if col summaries appear right of the detail in the outline
 public boolean getScenarioProtect() 
    Answer whether scenario protection is enabled or disabled
 Sheet getSheet() 
    used internally in the API to get the low level Sheet record represented by this Object.
 public HSSFSheetConditionalFormatting getSheetConditionalFormatting() 
 public String getSheetName() 
    Returns the name of this sheet
 public short getTopRow() 
    The top row in the visible view when the sheet is first viewed after opening it in a viewer
 public boolean getVerticallyCenter() 
    Determine whether printed output for this sheet will be vertically centered.
 public boolean getVerticallyCenter(boolean value) 
Deprecated! ( - Mar-2008) use getVerticallyCenter() instead

    TODO: Boolean not needed, remove after next release
 public HSSFWorkbook getWorkbook() 
    Return the parent workbook
 public  void groupColumn(short fromColumn,
    short toColumn) 
Deprecated! ( - Sep 2008) use #groupColumn(int, int)

 public  void groupColumn(int fromColumn,
    int toColumn) 
    Create an outline for the provided column range.
 public  void groupRow(int fromRow,
    int toRow) 
    Tie a range of cell together so that they can be collapsed or expanded
 protected  void insertChartRecords(List<Record> records) 
 public boolean isActive() 
 public boolean isColumnBroken(int column) 
    Determines if there is a page break at the indicated column
 public boolean isColumnHidden(short columnIndex) 
Deprecated! ( - Sep 2008) use #isColumnHidden(int)

 public boolean isColumnHidden(int columnIndex) 
    Get the hidden state for a given column.
 public boolean isDisplayFormulas() 
    Returns if formulas are displayed.
 public boolean isDisplayGridlines() 
    Returns if gridlines are displayed.
 public boolean isDisplayRowColHeadings() 
    Returns if RowColHeadings are displayed.
 public boolean isDisplayZeros() 
    Gets the flag indicating whether the window should show 0 (zero) in cells containing zero value. When false, cells with zero value appear blank instead of showing the number zero.

    In Excel 2003 this option can be changed in the Options dialog on the View tab.

 public boolean isGridsPrinted() 
    get whether gridlines are printed.
 public boolean isPrintGridlines() 
    Returns whether gridlines are printed.
 public boolean isRowBroken(int row) 
 public boolean isSelected() 
    Note - this is not the same as whether the sheet is focused (isActive)
 public Iterator<Row> iterator() 
 public  void protectSheet(String password) 
    Sets the protection enabled as well as the password
 public  void removeColumnBreak(int column) 
    Removes a page break at the indicated column
 public  void removeMergedRegion(int index) 
    removes a merged region of cells (hence letting them free)
 public  void removeRow(Row row) 
    Remove a row from this sheet. All cells contained in the row are removed as well
 public  void removeRowBreak(int row) 
    Removes the page break at the indicated row
 public Iterator<Row> rowIterator() 
 public  void setActive(boolean sel) 
    Sets whether sheet is selected.
 public  void setAlternativeExpression(boolean b) 
    whether alternate expression evaluation is on
 public  void setAlternativeFormula(boolean b) 
    whether alternative formula entry is on
 public  void setAutobreaks(boolean b) 
    show automatic page breaks or not
 public  void setColumnBreak(int column) 
    Sets a page break at the indicated column
 public  void setColumnGroupCollapsed(short columnNumber,
    boolean collapsed) 
Deprecated! ( - Sep 2008) use #setColumnGroupCollapsed(int, boolean)

 public  void setColumnGroupCollapsed(int columnNumber,
    boolean collapsed) 
    Expands or collapses a column group.
 public  void setColumnHidden(short columnIndex,
    boolean hidden) 
Deprecated! ( - Sep 2008) use #setColumnHidden(int, boolean)

 public  void setColumnHidden(int columnIndex,
    boolean hidden) 
    Get the visibility state for a given column.
 public  void setColumnWidth(short columnIndex,
    short width) 
Deprecated! ( - Sep 2008) use #setColumnWidth(int, int)

 public  void setColumnWidth(int columnIndex,
    int width) 
    Set the width (in units of 1/256th of a character width)

    The maximum column width for an individual cell is 255 characters. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font.

 public  void setDefaultColumnStyle(int column,
    CellStyle style) 
    Sets the default column style for a given column. POI will only apply this style to new cells added to the sheet.
 public  void setDefaultColumnWidth(short width) 
Deprecated! ( - Sep 2008) use #setDefaultColumnWidth(int)

 public  void setDefaultColumnWidth(int width) 
    set the default column width for the sheet (if the columns do not define their own width) in characters
 public  void setDefaultRowHeight(short height) 
    set the default row height for the sheet (if the rows do not define their own height) in twips (1/20 of a point)
 public  void setDefaultRowHeightInPoints(float height) 
    set the default row height for the sheet (if the rows do not define their own height) in points
 public  void setDialog(boolean b) 
    set whether sheet is a dialog sheet or not
 public  void setDisplayFormulas(boolean show) 
    Sets whether the formulas are shown in a viewer.
 public  void setDisplayGridlines(boolean show) 
    Sets whether the gridlines are shown in a viewer.
 public  void setDisplayGuts(boolean b) 
    set whether to display the guts or not
 public  void setDisplayRowColHeadings(boolean show) 
    Sets whether the RowColHeadings are shown in a viewer.
 public  void setDisplayZeros(boolean value) 
    Set whether the window should show 0 (zero) in cells containing zero value. When false, cells with zero value appear blank instead of showing the number zero.

    In Excel 2003 this option can be set in the Options dialog on the View tab.

 public  void setFitToPage(boolean b) 
    fit to page option is on
 public  void setForceFormulaRecalculation(boolean value) 
    Whether a record must be inserted or not at generation to indicate that formula must be recalculated when workbook is opened.
 public  void setGridsPrinted(boolean value) 
    set whether gridlines printed.
 public  void setHorizontallyCenter(boolean value) 
    determines whether the output is horizontally centered on the page.
 public  void setMargin(short margin,
    double size) 
    Sets the size of the margin in inches.
 public  void setPrintGridlines(boolean newPrintGridlines) 
    Turns on or off the printing of gridlines.
 public  void setRowBreak(int row) 
    Sets a page break at the indicated row
 public  void setRowGroupCollapsed(int rowIndex,
    boolean collapse) 
 public  void setRowSumsBelow(boolean b) 
    set if row summaries appear below detail in the outline
 public  void setRowSumsRight(boolean b) 
    set if col summaries appear right of the detail in the outline
 public  void setSelected(boolean sel) 
    Sets whether sheet is selected.
 public  void setVerticallyCenter(boolean value) 
    determines whether the output is vertically centered on the page.
 public  void setZoom(int numerator,
    int denominator) 
    Sets the zoom magnification for the sheet. The zoom is expressed as a fraction. For example to express a zoom of 75% use 3 for the numerator and 4 for the denominator.
 protected  void shiftMerged(int startRow,
    int endRow,
    int n,
    boolean isRow) 
    Shifts the merged regions left or right depending on mode

    TODO: MODE , this is only row specific

 public  void shiftRows(int startRow,
    int endRow,
    int n) 
    Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around. Calls shiftRows(startRow, endRow, n, false, false);

    Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

 public  void shiftRows(int startRow,
    int endRow,
    int n,
    boolean copyRowHeight,
    boolean resetOriginalRowHeight) 
    Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around

    Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

    TODO Might want to add bounds checking here

 public  void shiftRows(int startRow,
    int endRow,
    int n,
    boolean copyRowHeight,
    boolean resetOriginalRowHeight,
    boolean moveComments) 
    Shifts rows between startRow and endRow n number of rows. If you use a negative number, it will shift rows up. Code ensures that rows don't wrap around

    Additionally shifts merged regions that are completely defined in these rows (ie. merged 2 cells on a row to be shifted).

    TODO Might want to add bounds checking here

 public  void showInPane(short toprow,
    short leftcol) 
    Sets desktop window pane display area, when the file is first opened in a viewer.
 public  void ungroupColumn(short fromColumn,
    short toColumn) 
Deprecated! ( - Sep 2008) use #ungroupColumn(int, int)

 public  void ungroupColumn(int fromColumn,
    int toColumn) 
 public  void ungroupRow(int fromRow,
    int toRow) 
 protected  void validateColumn(int column) 
    Runs a bounds check for column numbers
 protected  void validateRow(int row) 
    Runs a bounds check for row numbers