org.apache.poi.xssf.usermodel
Class XSSFSheet

java.lang.Object
  extended by org.apache.poi.POIXMLDocumentPart
      extended by org.apache.poi.xssf.usermodel.XSSFSheet
All Implemented Interfaces:
java.lang.Iterable<org.apache.poi.ss.usermodel.Row>, org.apache.poi.ss.usermodel.Sheet
Direct Known Subclasses:
XSSFDialogsheet

public class XSSFSheet
extends POIXMLDocumentPart
implements org.apache.poi.ss.usermodel.Sheet

High level representation of a SpreadsheetML worksheet.

Sheets are the central structures within a workbook, and are where a user does most of his spreadsheet work. The most common type of sheet is the worksheet, which is represented as a grid of cells. Worksheet cells can contain text, numbers, dates, and formulas. Cells can also be formatted.


Field Summary
protected  org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet sheet
           
protected  org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet worksheet
           
 
Fields inherited from class org.apache.poi.POIXMLDocumentPart
DEFAULT_XML_OPTIONS
 
Fields inherited from interface org.apache.poi.ss.usermodel.Sheet
BottomMargin, FooterMargin, HeaderMargin, LeftMargin, PANE_LOWER_LEFT, PANE_LOWER_RIGHT, PANE_UPPER_LEFT, PANE_UPPER_RIGHT, RightMargin, TopMargin
 
Constructor Summary
protected XSSFSheet()
          Creates new XSSFSheet - called by XSSFWorkbook to create a sheet from scratch.
protected XSSFSheet(org.openxml4j.opc.PackagePart part, org.openxml4j.opc.PackageRelationship rel)
          Creates an XSSFSheet representing the given package part and relationship.
 
Method Summary
 int addMergedRegion(CellRangeAddress cra)
          Adds a merged region of cells (hence those cells form one).
 void autoSizeColumn(int column)
          Adjusts the column width to fit the contents.
 void autoSizeColumn(int column, boolean useMergedCells)
          Adjusts the column width to fit the contents.
protected  void commit()
          Save the content in the underlying package part.
 XSSFComment createComment()
          Creates a new comment for this sheet.
 XSSFDrawing createDrawingPatriarch()
          Create a new SpreadsheetML drawing.
 void createFreezePane(int colSplit, int rowSplit)
          Creates a split (freezepane).
 void createFreezePane(int colSplit, int rowSplit, int leftmostColumn, int topRow)
          Creates a split (freezepane).
 XSSFRow createRow(int rownum)
          Create a new row within the sheet and return the high level representation
 void createSplitPane(int xSplitPos, int ySplitPos, int leftmostColumn, int topRow, int activePane)
          Creates a split pane.
 java.lang.String getActiveCell()
          Return location of the active cell, e.g.
 boolean getAutobreaks()
          Flag indicating whether the sheet displays Automatic Page Breaks.
 XSSFComment getCellComment(int row, int column)
           
 int[] getColumnBreaks()
          Vertical page break information used for print layout view, page layout view, drawing print breaks in normal view, and for printing the worksheet.
 ColumnHelper getColumnHelper()
           
 int getColumnWidth(int columnIndex)
          Get the actual column width (in units of 1/256th of a character width )
protected  CommentsTable getCommentsTable()
          Returns the sheet's comments object if there is one, or null if not
 org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet getCTWorksheet()
          Provide access to the CTWorksheet bean holding this sheet's data
 int getDefaultColumnWidth()
          Get the default column width for the sheet (if the columns do not define their own width) in characters.
 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)
 float getDefaultRowHeightInPoints()
          Get the default row height for the sheet measued in point size (if the rows do not define their own height).
 boolean getDisplayGuts()
          Get whether to display the guts or not, default value is true
 org.apache.poi.ss.usermodel.Footer getEvenFooter()
          Returns the even footer.
 org.apache.poi.ss.usermodel.Header getEvenHeader()
          Returns the even header.
 org.apache.poi.ss.usermodel.Footer getFirstFooter()
          Returns the first page footer.
 org.apache.poi.ss.usermodel.Header getFirstHeader()
          Returns the first page header.
 int getFirstRowNum()
          Gets the first row on the sheet
 boolean getFitToPage()
          Flag indicating whether the Fit to Page print option is enabled.
 org.apache.poi.ss.usermodel.Footer getFooter()
          Returns the default footer for the sheet, creating one as needed.
 org.apache.poi.ss.usermodel.Header getHeader()
          Returns the default header for the sheet, creating one as needed.
 boolean getHorizontallyCenter()
          Determine whether printed output for this sheet will be horizontally centered.
 XSSFHyperlink getHyperlink(int row, int column)
           
 int getLastRowNum()
           
 short getLeftCol()
           
 double getMargin(short margin)
          Gets the size of the margin in inches.
 CellRangeAddress getMergedRegion(int index)
           
protected  int getNumberOfComments()
           
 int getNumHyperlinks()
           
 int getNumMergedRegions()
          Returns the number of merged regions defined in this worksheet
 org.apache.poi.ss.usermodel.Footer getOddFooter()
          Returns the odd footer.
 org.apache.poi.ss.usermodel.Header getOddHeader()
          Returns the odd header.
 PaneInformation getPaneInformation()
          Returns the information regarding the currently configured pane (split or freeze).
 int getPhysicalNumberOfRows()
          Returns the number of phsyically defined rows (NOT the number of rows in the sheet)
 XSSFPrintSetup getPrintSetup()
          Gets the print setup object.
 boolean getProtect()
          Answer whether protection is enabled or disabled
 XSSFRow getRow(int rownum)
          Returns the logical row ( 0-based).
 int[] getRowBreaks()
          Horizontal page break information used for print layout view, page layout view, drawing print breaks in normal view, and for printing the worksheet.
 boolean getRowSumsBelow()
          Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
 boolean getRowSumsRight()
          Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
 boolean getScenarioProtect()
          A flag indicating whether scenarios are locked when the sheet is protected.
 java.lang.String getSheetName()
          Returns the name of this sheet
 short getTopRow()
          The top row in the visible view when the sheet is first viewed after opening it in a viewer
 boolean getVerticallyCenter()
          Determine whether printed output for this sheet will be vertically centered.
 XSSFWorkbook getWorkbook()
          Returns the parent XSSFWorkbook
 void groupColumn(int fromColumn, int toColumn)
          Group between (0 based) columns
 void groupRow(int fromRow, int toRow)
          Tie a range of cell together so that they can be collapsed or expanded
 boolean hasComments()
          Does this sheet have any comments on it? We need to know, so we can decide about writing it to disk or not
 boolean isColumnBroken(short column)
          Determines if there is a page break at the indicated column
 boolean isColumnHidden(int columnIndex)
          Get the hidden state for a given column.
 boolean isDisplayFormulas()
          Gets the flag indicating whether this sheet should display formulas.
 boolean isDisplayGridlines()
          Gets the flag indicating whether this sheet displays the lines between rows and columns to make editing and reading easier.
 boolean isDisplayRowColHeadings()
          Gets the flag indicating whether this sheet should display row and column headings.
 boolean isPrintGridlines()
          Returns whether gridlines are printed.
 boolean isRowBroken(int row)
          Tests if there is a page break at the indicated row
 boolean isSelected()
          Returns a flag indicating whether this sheet is selected.
 java.util.Iterator<org.apache.poi.ss.usermodel.Row> iterator()
          Alias for rowIterator() to allow foreach loops
protected  void onDocumentCreate()
          Initialize worksheet data when creating a new sheet.
protected  void onDocumentRead()
          Initialize worksheet data when reading in an exisiting file.
protected  void read(java.io.InputStream is)
           
 void removeColumnBreak(short column)
          Removes a page break at the indicated column
 void removeMergedRegion(int index)
          Removes a merged region of cells (hence letting them free)
 void removeRow(org.apache.poi.ss.usermodel.Row row)
          Remove a row from this sheet.
 void removeRowBreak(int row)
          Removes the page break at the indicated row
 java.util.Iterator<org.apache.poi.ss.usermodel.Row> rowIterator()
           
 void setActiveCell(java.lang.String cellRef)
          Sets location of the active cell
 void setAutobreaks(boolean value)
          Flag indicating whether the sheet displays Automatic Page Breaks.
 void setCellComment(java.lang.String cellRef, XSSFComment comment)
          Assign a cell comment to a cell region in this worksheet
protected  void setCellHyperlink(XSSFHyperlink hyperlink)
           
 void setColumnBreak(short column)
          Sets a page break at the indicated column
 void setColumnGroupCollapsed(int columnNumber, boolean collapsed)
           
 void setColumnHidden(int columnIndex, boolean hidden)
          Get the visibility state for a given column.
 void setColumnWidth(int columnIndex, int width)
          Set the width (in units of 1/256th of a character width)
 void setDefaultColumnStyle(int column, org.apache.poi.ss.usermodel.CellStyle style)
           
 void setDefaultColumnWidth(int width)
          Specifies the number of characters of the maximum digit width of the normal style's font.
 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)
 void setDefaultRowHeightInPoints(float height)
          Sets default row height measured in point size.
 void setDisplayFormulas(boolean show)
          Sets the flag indicating whether this sheet should display formulas.
 void setDisplayGridlines(boolean show)
          Sets the flag indicating whether this sheet should display the lines between rows and columns to make editing and reading easier.
 void setDisplayGuts(boolean value)
          Set whether to display the guts or not
 void setDisplayRowColHeadings(boolean show)
          Sets the flag indicating whether this sheet should display row and column headings.
 void setFitToPage(boolean b)
          Flag indicating whether the Fit to Page print option is enabled.
 void setHorizontallyCenter(boolean value)
          Center on page horizontally when printing.
 void setMargin(short margin, double size)
          Sets the size of the margin in inches.
 void setPrintGridlines(boolean value)
          Turns on or off the printing of gridlines.
 void setRowBreak(int row)
          Sets a page break at the indicated row
 void setRowGroupCollapsed(int row, boolean collapse)
           
 void setRowSumsBelow(boolean value)
          Flag indicating whether summary rows appear below detail in an outline, when applying an outline.
 void setRowSumsRight(boolean value)
          Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.
 void setSelected(boolean value)
          Sets a flag indicating whether this sheet is selected.
 void setVerticallyCenter(boolean value)
          Whether the output is vertically centered on the page.
 void setZoom(int scale)
          Window zoom magnification for current view representing percent values.
 void setZoom(int numerator, int denominator)
          Sets the zoom magnication for the sheet.
 void shiftRows(int startRow, int endRow, int n)
          Shifts rows between startRow and endRow n number of rows.
 void shiftRows(int startRow, int endRow, int n, boolean copyRowHeight, boolean resetOriginalRowHeight)
          Shifts rows between startRow and endRow n number of rows.
 void showInPane(short toprow, short leftcol)
          Location of the top left visible cell Location of the top left visible cell in the bottom right pane (when in Left-to-Right mode).
 void ungroupColumn(int fromColumn, int toColumn)
           
 void ungroupRow(int fromRow, int toRow)
          Ungroup a range of rows that were previously groupped
protected  void write(java.io.OutputStream out)
           
 
Methods inherited from class org.apache.poi.POIXMLDocumentPart
addRelation, createRelationship, createRelationship, createRelationship, getPackagePart, getPackageRelationship, getParent, getRelations, onSave, read, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sheet

protected org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet sheet

worksheet

protected org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet worksheet
Constructor Detail

XSSFSheet

protected XSSFSheet()
Creates new XSSFSheet - called by XSSFWorkbook to create a sheet from scratch.

See Also:
XSSFWorkbook.createSheet()

XSSFSheet

protected XSSFSheet(org.openxml4j.opc.PackagePart part,
                    org.openxml4j.opc.PackageRelationship rel)
Creates an XSSFSheet representing the given package part and relationship. Should only be called by XSSFWorkbook when reading in an exisiting file.

Parameters:
part - - The package part that holds xml data represenring this sheet.
rel - - the relationship of the given package part in the underlying OPC package
Method Detail

getWorkbook

public XSSFWorkbook getWorkbook()
Returns the parent XSSFWorkbook

Returns:
the parent XSSFWorkbook

onDocumentRead

protected void onDocumentRead()
Initialize worksheet data when reading in an exisiting file.

Overrides:
onDocumentRead in class POIXMLDocumentPart

read

protected void read(java.io.InputStream is)
             throws java.io.IOException
Throws:
java.io.IOException

onDocumentCreate

protected void onDocumentCreate()
Initialize worksheet data when creating a new sheet.

Overrides:
onDocumentCreate in class POIXMLDocumentPart

getCTWorksheet

public org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet getCTWorksheet()
Provide access to the CTWorksheet bean holding this sheet's data

Returns:
the CTWorksheet bean holding this sheet's data

getColumnHelper

public ColumnHelper getColumnHelper()

getSheetName

public java.lang.String getSheetName()
Returns the name of this sheet

Returns:
the name of this sheet

addMergedRegion

public int addMergedRegion(CellRangeAddress cra)
Adds a merged region of cells (hence those cells form one).

Specified by:
addMergedRegion in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
cra - (rowfrom/colfrom-rowto/colto) to merge
Returns:
index of this region

autoSizeColumn

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.

Specified by:
autoSizeColumn in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
column - the column index

autoSizeColumn

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.

Specified by:
autoSizeColumn in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
column - the column index
useMergedCells - whether to use the contents of merged cells when calculating the width of the column

createDrawingPatriarch

public XSSFDrawing createDrawingPatriarch()
Create a new SpreadsheetML drawing. If this sheet already contains a drawing - return that.

Specified by:
createDrawingPatriarch in interface org.apache.poi.ss.usermodel.Sheet
Returns:
a SpreadsheetML drawing

createFreezePane

public void createFreezePane(int colSplit,
                             int rowSplit,
                             int leftmostColumn,
                             int topRow)
Creates a split (freezepane). Any existing freezepane or split pane is overwritten.

Specified by:
createFreezePane in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
colSplit - Horizonatal position of split.
rowSplit - Vertical position of split.
topRow - Top row visible in bottom pane
leftmostColumn - Left column visible in right pane.

createFreezePane

public void createFreezePane(int colSplit,
                             int rowSplit)
Creates a split (freezepane). Any existing freezepane or split pane is overwritten.

Specified by:
createFreezePane in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
colSplit - Horizonatal position of split.
rowSplit - Vertical position of split.

createComment

public XSSFComment createComment()
Creates a new comment for this sheet. You still need to assign it to a cell though


createRow

public XSSFRow createRow(int rownum)
Create a new row within the sheet and return the high level representation

Specified by:
createRow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
rownum - row number
Returns:
High level XSSFRow object representing a row in the sheet
See Also:
removeRow(org.apache.poi.ss.usermodel.Row)

createSplitPane

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.

Specified by:
createSplitPane in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
xSplitPos - Horizonatal position of split (in 1/20th of a point).
ySplitPos - Vertical position of split (in 1/20th of a point).
topRow - Top row visible in bottom pane
leftmostColumn - Left column visible in right pane.
activePane - Active pane. One of: PANE_LOWER_RIGHT, PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
See Also:
Sheet.PANE_LOWER_LEFT, Sheet.PANE_LOWER_RIGHT, Sheet.PANE_UPPER_LEFT, Sheet.PANE_UPPER_RIGHT

getCellComment

public XSSFComment getCellComment(int row,
                                  int column)
Specified by:
getCellComment in interface org.apache.poi.ss.usermodel.Sheet

getHyperlink

public XSSFHyperlink getHyperlink(int row,
                                  int column)

getColumnBreaks

public int[] getColumnBreaks()
Vertical page break information used for print layout view, page layout view, drawing print breaks in normal view, and for printing the worksheet.

Specified by:
getColumnBreaks in interface org.apache.poi.ss.usermodel.Sheet
Returns:
column indexes of all the vertical page breaks, never null

getColumnWidth

public int getColumnWidth(int columnIndex)
Get the actual column width (in units of 1/256th of a character width )

Note, the returned value is always gerater that getDefaultColumnWidth() because the latter does not include margins. Actual column width measured as the number of characters of the maximum digit width of the numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. There are 4 pixels of margin padding (two on each side), plus 1 pixel padding for the gridlines.

Specified by:
getColumnWidth in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
columnIndex - - the column to set (0-based)
Returns:
width - the width in units of 1/256th of a character width

getDefaultColumnWidth

public int getDefaultColumnWidth()
Get the default column width for the sheet (if the columns do not define their own width) in characters.

Note, this value is different from getColumnWidth(int). The latter is always greater and includes 4 pixels of margin padding (two on each side), plus 1 pixel padding for the gridlines.

Specified by:
getDefaultColumnWidth in interface org.apache.poi.ss.usermodel.Sheet
Returns:
column width, default value is 8

getDefaultRowHeight

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)

Specified by:
getDefaultRowHeight in interface org.apache.poi.ss.usermodel.Sheet
Returns:
default row height

getDefaultRowHeightInPoints

public float getDefaultRowHeightInPoints()
Get the default row height for the sheet measued in point size (if the rows do not define their own height).

Specified by:
getDefaultRowHeightInPoints in interface org.apache.poi.ss.usermodel.Sheet
Returns:
default row height in points

getDisplayGuts

public boolean getDisplayGuts()
Get whether to display the guts or not, default value is true

Specified by:
getDisplayGuts in interface org.apache.poi.ss.usermodel.Sheet
Returns:
boolean - guts or no guts

setDisplayGuts

public void setDisplayGuts(boolean value)
Set whether to display the guts or not

Specified by:
setDisplayGuts in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - - guts or no guts

getFirstRowNum

public int getFirstRowNum()
Gets the first row on the sheet

Specified by:
getFirstRowNum in interface org.apache.poi.ss.usermodel.Sheet
Returns:
the number of the first logical row on the sheet, zero based

getFitToPage

public boolean getFitToPage()
Flag indicating whether the Fit to Page print option is enabled.

Specified by:
getFitToPage in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true

getFooter

public org.apache.poi.ss.usermodel.Footer getFooter()
Returns the default footer for the sheet, creating one as needed. You may also want to look at getFirstFooter(), getOddFooter() and getEvenFooter()

Specified by:
getFooter in interface org.apache.poi.ss.usermodel.Sheet

getHeader

public org.apache.poi.ss.usermodel.Header getHeader()
Returns the default header for the sheet, creating one as needed. You may also want to look at getFirstHeader(), getOddHeader() and getEvenHeader()

Specified by:
getHeader in interface org.apache.poi.ss.usermodel.Sheet

getOddFooter

public org.apache.poi.ss.usermodel.Footer getOddFooter()
Returns the odd footer. Used on all pages unless other footers also present, when used on only odd pages.


getEvenFooter

public org.apache.poi.ss.usermodel.Footer getEvenFooter()
Returns the even footer. Not there by default, but when set, used on even pages.


getFirstFooter

public org.apache.poi.ss.usermodel.Footer getFirstFooter()
Returns the first page footer. Not there by default, but when set, used on the first page.


getOddHeader

public org.apache.poi.ss.usermodel.Header getOddHeader()
Returns the odd header. Used on all pages unless other headers also present, when used on only odd pages.


getEvenHeader

public org.apache.poi.ss.usermodel.Header getEvenHeader()
Returns the even header. Not there by default, but when set, used on even pages.


getFirstHeader

public org.apache.poi.ss.usermodel.Header getFirstHeader()
Returns the first page header. Not there by default, but when set, used on the first page.


getHorizontallyCenter

public boolean getHorizontallyCenter()
Determine whether printed output for this sheet will be horizontally centered.

Specified by:
getHorizontallyCenter in interface org.apache.poi.ss.usermodel.Sheet

getLastRowNum

public int getLastRowNum()
Specified by:
getLastRowNum in interface org.apache.poi.ss.usermodel.Sheet

getLeftCol

public short getLeftCol()
Specified by:
getLeftCol in interface org.apache.poi.ss.usermodel.Sheet

getMargin

public double getMargin(short margin)
Gets the size of the margin in inches.

Specified by:
getMargin in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
margin - which margin to get
Returns:
the size of the margin
See Also:
Sheet.LeftMargin, Sheet.RightMargin, Sheet.TopMargin, Sheet.BottomMargin, Sheet.HeaderMargin, Sheet.FooterMargin

setMargin

public void setMargin(short margin,
                      double size)
Sets the size of the margin in inches.

Specified by:
setMargin in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
margin - which margin to get
size - the size of the margin
See Also:
Sheet.LeftMargin, Sheet.RightMargin, Sheet.TopMargin, Sheet.BottomMargin, Sheet.HeaderMargin, Sheet.FooterMargin

getMergedRegion

public CellRangeAddress getMergedRegion(int index)
Returns:
the merged region at the specified index
Throws:
java.lang.IllegalStateException - if this worksheet does not contain merged regions

getNumMergedRegions

public int getNumMergedRegions()
Returns the number of merged regions defined in this worksheet

Specified by:
getNumMergedRegions in interface org.apache.poi.ss.usermodel.Sheet
Returns:
number of merged regions in this worksheet

getNumHyperlinks

public int getNumHyperlinks()

getPaneInformation

public PaneInformation getPaneInformation()
Returns the information regarding the currently configured pane (split or freeze).

Specified by:
getPaneInformation in interface org.apache.poi.ss.usermodel.Sheet
Returns:
null if no pane configured, or the pane information.

getPhysicalNumberOfRows

public int getPhysicalNumberOfRows()
Returns the number of phsyically defined rows (NOT the number of rows in the sheet)

Specified by:
getPhysicalNumberOfRows in interface org.apache.poi.ss.usermodel.Sheet
Returns:
the number of phsyically defined rows

getPrintSetup

public XSSFPrintSetup getPrintSetup()
Gets the print setup object.

Specified by:
getPrintSetup in interface org.apache.poi.ss.usermodel.Sheet
Returns:
The user model for the print setup object.

getProtect

public boolean getProtect()
Answer whether protection is enabled or disabled

Specified by:
getProtect in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true => protection enabled; false => protection disabled

getRow

public XSSFRow getRow(int rownum)
Returns the logical row ( 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.

Specified by:
getRow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
rownum - row to get
Returns:
XSSFRow representing the rownumber or null if its not defined on the sheet

getRowBreaks

public int[] getRowBreaks()
Horizontal page break information used for print layout view, page layout view, drawing print breaks in normal view, and for printing the worksheet.

Specified by:
getRowBreaks in interface org.apache.poi.ss.usermodel.Sheet
Returns:
row indexes of all the horizontal page breaks, never null

getRowSumsBelow

public boolean getRowSumsBelow()
Flag indicating whether summary rows appear below detail in an outline, when applying an outline.

When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.

When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.

Specified by:
getRowSumsBelow in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if row summaries appear below detail in the outline

setRowSumsBelow

public void setRowSumsBelow(boolean value)
Flag indicating whether summary rows appear below detail in an outline, when applying an outline.

When true a summary row is inserted below the detailed data being summarized and a new outline level is established on that row.

When false a summary row is inserted above the detailed data being summarized and a new outline level is established on that row.

Specified by:
setRowSumsBelow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - true if row summaries appear below detail in the outline

getRowSumsRight

public boolean getRowSumsRight()
Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.

When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.

When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.

Specified by:
getRowSumsRight in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if col summaries appear right of the detail in the outline

setRowSumsRight

public void setRowSumsRight(boolean value)
Flag indicating whether summary columns appear to the right of detail in an outline, when applying an outline.

When true a summary column is inserted to the right of the detailed data being summarized and a new outline level is established on that column.

When false a summary column is inserted to the left of the detailed data being summarized and a new outline level is established on that column.

Specified by:
setRowSumsRight in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - true if col summaries appear right of the detail in the outline

getScenarioProtect

public boolean getScenarioProtect()
A flag indicating whether scenarios are locked when the sheet is protected.

Specified by:
getScenarioProtect in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true => protection enabled; false => protection disabled

getTopRow

public short getTopRow()
The top row in the visible view when the sheet is first viewed after opening it in a viewer

Specified by:
getTopRow in interface org.apache.poi.ss.usermodel.Sheet
Returns:
integer indicating the rownum (0 based) of the top row

getVerticallyCenter

public boolean getVerticallyCenter()
Determine whether printed output for this sheet will be vertically centered.

Returns:
whether printed output for this sheet will be vertically centered.

groupColumn

public void groupColumn(int fromColumn,
                        int toColumn)
Group between (0 based) columns

Specified by:
groupColumn in interface org.apache.poi.ss.usermodel.Sheet

groupRow

public void groupRow(int fromRow,
                     int toRow)
Tie a range of cell together so that they can be collapsed or expanded

Specified by:
groupRow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
fromRow - start row (0-based)
toRow - end row (0-based)

isColumnBroken

public boolean isColumnBroken(short column)
Determines if there is a page break at the indicated column

Specified by:
isColumnBroken in interface org.apache.poi.ss.usermodel.Sheet

isColumnHidden

public boolean isColumnHidden(int columnIndex)
Get the hidden state for a given column.

Specified by:
isColumnHidden in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
columnIndex - - the column to set (0-based)
Returns:
hidden - false if the column is visible

isDisplayFormulas

public boolean isDisplayFormulas()
Gets the flag indicating whether this sheet should display formulas.

Specified by:
isDisplayFormulas in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if this sheet should display formulas.

isDisplayGridlines

public boolean isDisplayGridlines()
Gets the flag indicating whether this sheet displays the lines between rows and columns to make editing and reading easier.

Specified by:
isDisplayGridlines in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if this sheet displays gridlines.
See Also:
to check if printing of gridlines is turned on or off

setDisplayGridlines

public void setDisplayGridlines(boolean show)
Sets the flag indicating whether this sheet should display the lines between rows and columns to make editing and reading easier. To turn printing of gridlines use setPrintGridlines(boolean)

Specified by:
setDisplayGridlines in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
show - true if this sheet should display gridlines.
See Also:
setPrintGridlines(boolean)

isDisplayRowColHeadings

public boolean isDisplayRowColHeadings()
Gets the flag indicating whether this sheet should display row and column headings.

Row heading are the row numbers to the side of the sheet

Column heading are the letters or numbers that appear above the columns of the sheet

Specified by:
isDisplayRowColHeadings in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if this sheet should display row and column headings.

setDisplayRowColHeadings

public void setDisplayRowColHeadings(boolean show)
Sets the flag indicating whether this sheet should display row and column headings.

Row heading are the row numbers to the side of the sheet

Column heading are the letters or numbers that appear above the columns of the sheet

Specified by:
setDisplayRowColHeadings in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
show - true if this sheet should display row and column headings.

isPrintGridlines

public boolean isPrintGridlines()
Returns whether gridlines are printed.

Specified by:
isPrintGridlines in interface org.apache.poi.ss.usermodel.Sheet
Returns:
whether gridlines are printed

setPrintGridlines

public void setPrintGridlines(boolean value)
Turns on or off the printing of gridlines.

Specified by:
setPrintGridlines in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - boolean to turn on or off the printing of gridlines

isRowBroken

public boolean isRowBroken(int row)
Tests if there is a page break at the indicated row

Specified by:
isRowBroken in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
row - index of the row to test
Returns:
true if there is a page break at the indicated row

setRowBreak

public void setRowBreak(int row)
Sets a page break at the indicated row

Specified by:
setRowBreak in interface org.apache.poi.ss.usermodel.Sheet

removeColumnBreak

public void removeColumnBreak(short column)
Removes a page break at the indicated column

Specified by:
removeColumnBreak in interface org.apache.poi.ss.usermodel.Sheet

removeMergedRegion

public void removeMergedRegion(int index)
Removes a merged region of cells (hence letting them free)

Specified by:
removeMergedRegion in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
index - of the region to unmerge

removeRow

public void removeRow(org.apache.poi.ss.usermodel.Row row)
Remove a row from this sheet. All cells contained in the row are removed as well

Specified by:
removeRow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
row - the row to remove.

removeRowBreak

public void removeRowBreak(int row)
Removes the page break at the indicated row

Specified by:
removeRowBreak in interface org.apache.poi.ss.usermodel.Sheet

rowIterator

public java.util.Iterator<org.apache.poi.ss.usermodel.Row> rowIterator()
Specified by:
rowIterator in interface org.apache.poi.ss.usermodel.Sheet
Returns:
an iterator of the PHYSICAL rows. Meaning the 3rd element may not be the third row if say for instance the second row is undefined. Call getRowNum() on each row if you care which one it is.

iterator

public java.util.Iterator<org.apache.poi.ss.usermodel.Row> iterator()
Alias for rowIterator() to allow foreach loops

Specified by:
iterator in interface java.lang.Iterable<org.apache.poi.ss.usermodel.Row>

getAutobreaks

public boolean getAutobreaks()
Flag indicating whether the sheet displays Automatic Page Breaks.

Specified by:
getAutobreaks in interface org.apache.poi.ss.usermodel.Sheet
Returns:
true if the sheet displays Automatic Page Breaks.

setAutobreaks

public void setAutobreaks(boolean value)
Flag indicating whether the sheet displays Automatic Page Breaks.

Specified by:
setAutobreaks in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - true if the sheet displays Automatic Page Breaks.

setColumnBreak

public void setColumnBreak(short column)
Sets a page break at the indicated column

Specified by:
setColumnBreak in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
column - the column to break

setColumnGroupCollapsed

public void setColumnGroupCollapsed(int columnNumber,
                                    boolean collapsed)
Specified by:
setColumnGroupCollapsed in interface org.apache.poi.ss.usermodel.Sheet

setRowGroupCollapsed

public void setRowGroupCollapsed(int row,
                                 boolean collapse)
Specified by:
setRowGroupCollapsed in interface org.apache.poi.ss.usermodel.Sheet

setColumnHidden

public void setColumnHidden(int columnIndex,
                            boolean hidden)
Get the visibility state for a given column.

Specified by:
setColumnHidden in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
columnIndex - - the column to get (0-based)
hidden - - the visiblity state of the column

setColumnWidth

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

Specified by:
setColumnWidth in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
columnIndex - - the column to set (0-based)
width - - the width in units of 1/256th of a character width

setDefaultColumnStyle

public void setDefaultColumnStyle(int column,
                                  org.apache.poi.ss.usermodel.CellStyle style)
Specified by:
setDefaultColumnStyle in interface org.apache.poi.ss.usermodel.Sheet

setDefaultColumnWidth

public void setDefaultColumnWidth(int width)
Specifies the number of characters of the maximum digit width of the normal style's font. This value does not include margin padding or extra padding for gridlines. It is only the number of characters.

Specified by:
setDefaultColumnWidth in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
width - the number of characters. Default value is 8.

setDefaultRowHeight

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)

Specified by:
setDefaultRowHeight in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
height - default row height in twips (1/20 of a point)

setDefaultRowHeightInPoints

public void setDefaultRowHeightInPoints(float height)
Sets default row height measured in point size.

Specified by:
setDefaultRowHeightInPoints in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
height - default row height measured in point size.

setDisplayFormulas

public void setDisplayFormulas(boolean show)
Sets the flag indicating whether this sheet should display formulas.

Specified by:
setDisplayFormulas in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
show - true if this sheet should display formulas.

setFitToPage

public void setFitToPage(boolean b)
Flag indicating whether the Fit to Page print option is enabled.

Specified by:
setFitToPage in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
b - true if the Fit to Page print option is enabled.

setHorizontallyCenter

public void setHorizontallyCenter(boolean value)
Center on page horizontally when printing.

Specified by:
setHorizontallyCenter in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - whether to center on page horizontally when printing.

setVerticallyCenter

public void setVerticallyCenter(boolean value)
Whether the output is vertically centered on the page.

Specified by:
setVerticallyCenter in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - true to vertically center, false otherwise.

setZoom

public void setZoom(int numerator,
                    int denominator)
Sets the zoom magnication 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.

Specified by:
setZoom in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
numerator - The numerator for the zoom magnification.
denominator - The denominator for the zoom magnification.
See Also:
setZoom(int)

setZoom

public void setZoom(int scale)
Window zoom magnification for current view representing percent values. Valid values range from 10 to 400. Horizontal & Vertical scale together. For example:
 10 - 10%
 20 - 20%
 ...
 100 - 100%
 ...
 400 - 400%
 
Current view can be Normal, Page Layout, or Page Break Preview.

Parameters:
scale - window zoom magnification
Throws:
java.lang.IllegalArgumentException - if scale is invalid

shiftRows

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).

Specified by:
shiftRows in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
startRow - the row to start shifting
endRow - the row to end shifting
n - the number of rows to shift

shiftRows

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).

Specified by:
shiftRows in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
startRow - the row to start shifting
endRow - the row to end shifting
n - the number of rows to shift
copyRowHeight - whether to copy the row height during the shift
resetOriginalRowHeight - whether to set the original row's height to the default

showInPane

public void showInPane(short toprow,
                       short leftcol)
Location of the top left visible cell Location of the top left visible cell in the bottom right pane (when in Left-to-Right mode).

Specified by:
showInPane in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
toprow - the top row to show in desktop window pane
leftcol - the left column to show in desktop window pane

ungroupColumn

public void ungroupColumn(int fromColumn,
                          int toColumn)
Specified by:
ungroupColumn in interface org.apache.poi.ss.usermodel.Sheet

ungroupRow

public void ungroupRow(int fromRow,
                       int toRow)
Ungroup a range of rows that were previously groupped

Specified by:
ungroupRow in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
fromRow - start row (0-based)
toRow - end row (0-based)

isSelected

public boolean isSelected()
Returns a flag indicating whether this sheet is selected.

When only 1 sheet is selected and active, this value should be in synch with the activeTab value. In case of a conflict, the Start Part setting wins and sets the active sheet tab.

Note: multiple sheets can be selected, but only one sheet can be active at one time.

Returns:
true if this sheet is selected

setSelected

public void setSelected(boolean value)
Sets a flag indicating whether this sheet is selected.

When only 1 sheet is selected and active, this value should be in synch with the activeTab value. In case of a conflict, the Start Part setting wins and sets the active sheet tab.

Note: multiple sheets can be selected, but only one sheet can be active at one time.

Specified by:
setSelected in interface org.apache.poi.ss.usermodel.Sheet
Parameters:
value - true if this sheet is selected

setCellComment

public void setCellComment(java.lang.String cellRef,
                           XSSFComment comment)
Assign a cell comment to a cell region in this worksheet

Parameters:
cellRef - cell region
comment - the comment to assign

setCellHyperlink

protected void setCellHyperlink(XSSFHyperlink hyperlink)

getActiveCell

public java.lang.String getActiveCell()
Return location of the active cell, e.g. A1.

Returns:
the location of the active cell.

setActiveCell

public void setActiveCell(java.lang.String cellRef)
Sets location of the active cell

Parameters:
cellRef - the location of the active cell, e.g. A1..

hasComments

public boolean hasComments()
Does this sheet have any comments on it? We need to know, so we can decide about writing it to disk or not


getNumberOfComments

protected int getNumberOfComments()

getCommentsTable

protected CommentsTable getCommentsTable()
Returns the sheet's comments object if there is one, or null if not


commit

protected void commit()
               throws java.io.IOException
Description copied from class: POIXMLDocumentPart
Save the content in the underlying package part. Default implementation is empty meaning that the package part is left unmodified. Sub-classes should override and add logic to marshal the "model" into Ooxml4J. For example, the code saving a generic XML entry may look as follows:

 protected void commit() throws IOException {
   PackagePart part = getPackagePart();
   OutputStream out = part.getOutputStream();
   XmlObject bean = getXmlBean(); //the "model" which holds changes in memory
   bean.save(out, DEFAULT_XML_OPTIONS);
   out.close();
 }
  

Overrides:
commit in class POIXMLDocumentPart
Throws:
java.io.IOException

write

protected void write(java.io.OutputStream out)
              throws java.io.IOException
Throws:
java.io.IOException


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.