Top Description Inners Fields Constructors Methods
org.apache.poi.hssf.model

public final Class InternalSheet

extends Object
Class Inheritance
Annotations
@Internal
Imports
java.util.ArrayList, .Iterator, .List, org.apache.logging.log4j.LogManager, .Logger, org.apache.poi.hssf.record.*, .Record, org.apache.poi.hssf.record.aggregates.ChartSubstreamRecordAggregate, .ColumnInfoRecordsAggregate, .ConditionalFormattingTable, .CustomViewSettingsRecordAggregate, .DataValidityTable, .MergedCellsTable, .PageSettingsBlock, .RecordAggregate, .RecordAggregate.PositionTrackingVisitor, .RecordAggregate.RecordVisitor, .RowRecordsAggregate, .WorksheetProtectionBlock, org.apache.poi.hssf.usermodel.HSSFSheet, org.apache.poi.ss.formula.FormulaShifter, org.apache.poi.ss.usermodel.Sheet, org.apache.poi.ss.util.CellRangeAddress, .PaneInformation, org.apache.poi.util.Internal, .RecordFormatException

Low level model implementation of a Sheet (one workbook contains many sheets) This file contains the low level binary records starting at the sheets BOF and ending with the sheets EOF. Use HSSFSheet for a high level representation.

The structures of the highlevel API use references to this to perform most of their operations. Its probably unwise to use these low level structures directly unless you really know what you're doing. I recommend you read the Microsoft Excel 97 Developer's Kit (Microsoft Press) and the documentation at https://sc.openoffice.org/excelfileformat.pdf before even attempting to use this.

See Also
InternalWorkbook, HSSFSheet

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
public static class

Field Summary

Modifier and TypeField and Description
pack-priv ColumnInfoRecordsAggregate
_columnInfos

always present in this POI object, not always written to Excel file

private DataValidityTable
private DimensionsRecord
_dimensions

the DimensionsRecord is always present

private GutsRecord
protected boolean
_isUncalced

Add an UncalcedRecord if not true indicating formulas have not been calculated

private final MergedCellsTable
_mergedCellsTable

java object always present, but if empty no BIFF records are written

private final WorksheetProtectionBlock
_protectionBlock

'Worksheet Protection Block' Aggregate object is always present, but possibly empty.

private PageSettingsBlock
private final List<RecordBase>
protected final RowRecordsAggregate
_rowsAggregate

always present

protected SelectionRecord
public static final short
private ConditionalFormattingTable
protected DefaultColWidthRecord
protected DefaultRowHeightRecord
protected GridsetRecord
public static final short
private static final Logger
public static final byte
public static final byte
public static final byte
public static final byte
protected PrintGridlinesRecord
protected PrintHeadersRecord
public static final short
private Iterator<RowRecord>
public static final short
protected WindowTwoRecord

Constructor Summary

AccessConstructor and Description
private
private

Method Summary

Modifier and TypeMethod and Description
public int
addMergedRegion(int rowFrom, int colFrom, int rowTo, int colTo)

public void
addRow(RowRecord
the row record to be added
row
)

Adds a row record to the sheet

This method is "loc" sensitive.

public void
addValueRecord(int
the row to add the cell value to
row
,
CellValueRecordInterface
the cell value record itself.
col
)

Adds a value record to the sheet's contained binary records (i.e. LabelSSTRecord or NumberRecord).

public int

Returns:

location of EscherAggregate record. if no EscherAggregate record is found return -1
aggregateDrawingRecords
(DrawingManager2
The DrawingManager2 for our workbook
drawingManager
,
boolean
Should one be created if missing?
createIfMissing
)

Finds the DrawingRecord for our sheet, and attaches it to the DrawingManager (which knows about the overall DrawingGroup for our workbook).

public InternalSheet

Returns:

the cloned sheet
cloneSheet
()

Clones the low level records of this sheet and returns the new sheet instance.

pack-priv static BOFRecord
createBOF()

creates the BOF record

private static CalcCountRecord
createCalcCount()

creates the CalcCount record and sets it to 100 (default number of iterations)

private static CalcModeRecord
createCalcMode()

creates the CalcMode record and sets it to 1 (automatic formula caculation)

private static DefaultColWidthRecord
createDefaultColWidth()

creates the DefaultColWidth Record and sets it to 8

private static DefaultRowHeightRecord
createDefaultRowHeight()

creates the DefaultRowHeight Record and sets its options to 0 and rowheight to 0xff

private static DeltaRecord
createDelta()

creates the Delta record and sets it to 0.0010 (default accuracy)

private static DimensionsRecord
createDimensions()

creates the Dimensions Record and sets it to bogus values (you should set this yourself or let the high level API do it for you)

public void
createFreezePane(int
Horizontal position of split.
colSplit
,
int
Vertical position of split.
rowSplit
,
int
Top row visible in bottom pane
topRow
,
int
Left column visible in right pane.
leftmostColumn
)

Creates a split (freezepane).

private static GridsetRecord
createGridset()

creates the Gridset record and sets it to true (user has mucked with the gridlines)

private static GutsRecord
createGuts()

creates the Guts record and sets leftrow/topcol guttter and rowlevelmax/collevelmax to 0

private static IterationRecord
createIteration()

creates the Iteration record and sets it to false (don't iteratively calculate formulas)

private static PrintGridlinesRecord
createPrintGridlines()

creates the PrintGridlines record and sets it to false (that makes for ugly sheets).

private static PrintHeadersRecord
createPrintHeaders()

creates the PrintHeaders record and sets it to false (we don't create headers yet so why print them)

private static RefModeRecord
createRefMode()

creates the RefMode record and sets it to A1 Mode (default reference mode)

private static SaveRecalcRecord
createSaveRecalc()

creates the SaveRecalc record and sets it to true (recalculate before saving)

private static SelectionRecord
createSelection()

Creates the Selection record and sets it to nothing selected

public static InternalSheet

Returns:

Sheet object with all values set to those read from the file
createSheet
(RecordStream
the stream to read records from
rs
)

read support (offset used as starting point for search) for low level API.

public static InternalSheet

Returns:

Sheet object with all values set to defaults
createSheet
()

Creates a sheet with all the usual records minus values and the "index" record (not required).

public void
createSplitPane(int
Horizontal position of split (in 1/20th of a point).
xSplitPos
,
int
Vertical position of split (in 1/20th of a point).
ySplitPos
,
int
Top row visible in bottom pane
topRow
,
int
Left column visible in right pane.
leftmostColumn
,
int
Active pane. One of: PANE_LOWER_RIGHT, PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
activePane
)

Creates a split pane.

private static WindowTwoRecord
createWindowTwo()

creates the WindowTwo Record and sets it to:

options = 0x6b6

toprow = 0

leftcol = 0

headercolor = 0x40

pagebreakzoom = 0x0

normalzoom = 0x0

private static WSBoolRecord
createWSBool()

creates the WSBoolRecord and sets its values to defaults

public Record

Returns:

the matching record or null if it wasn't found
findFirstRecordBySid
(short
the sid to search for
sid
)

Returns the first occurrence of a record matching a particular sid.

public int

Returns:

the record position of the matching record or -1 if no match is made.
findFirstRecordLocBySid
(short
the sid to search for
sid
)

Finds the first occurrence of a record matching a particular sid and returns it's position.

public short

Returns:

column of the active cell
getActiveCellCol
()

public int

Returns:

row the active row index
getActiveCellRow
()

Returns the active row

public Iterator<CellValueRecordInterface>

Returns:

Iterator of CellValueRecordInterface representing the value records
getCellValueIterator
()

Get all the value records (from LOC).

public int
getColumnOutlineLevel(int columnIndex)

public int

Returns:

column width in units of 1/256th of a character width
getColumnWidth
(int
index
columnIndex
)

get the width of a given column in units of 1/256th of a character width

public ConditionalFormattingTable
public int

Returns:

default column width
getDefaultColumnWidth
()

get the default column width for the sheet (if the columns do not define their own width)

public short

Returns:

default row height
getDefaultRowHeight
()

get the default row height for the sheet (if the rows do not define their own height)

public GridsetRecord

Returns:

the gridset record for this sheet
getGridsetRecord
()

Gets the gridset record for this sheet.

private GutsRecord
public short
public int
private MergedCellsTable
public CellRangeAddress
getMergedRegionAt(int index)

public int
public RowRecord

Returns:

RowRecord representing the next row record or NULL if there are no more
getNextRow
()

get the NEXT RowRecord (from LOC).

public NoteRecord[]

Returns:

never null, typically empty array
getNoteRecords
()

Get the NoteRecords (related to cell comments) for this sheet

public int
public DataValidityTable
public PageSettingsBlock
public PaneInformation

Returns:

null if no pane configured, or the pane information.
getPaneInformation
()

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

public PrintGridlinesRecord

Returns:

PrintGridlinesRecord for the sheet.
getPrintGridlines
()

Returns the PrintGridlinesRecord.

public PrintHeadersRecord

Returns:

PrintHeadersRecord for the sheet.
getPrintHeaders
()

Returns the PrintHeadersRecord.

public WorksheetProtectionBlock

Returns:

the WorksheetProtectionBlock for this sheet
getProtectionBlock
()

public List<RecordBase>
public RowRecord

Returns:

RowRecord representing the next row record or NULL if there are no more
getRow
(int
which row to return (careful with LOC)
rownum
)

get the NEXT (from LOC) RowRecord where rownumber matches the given rownum.

public RowRecordsAggregate
public SelectionRecord
private int

Returns:

count of bytes from end of INDEX record to first ROW record.
getSizeOfInitialSheetRecords
(int
index of record after which INDEX record is to be placed
bofRecordIndex
)

'initial sheet records' are between INDEX and the 'Row Blocks'

public short
public boolean

Returns:

whether an uncalced record must be inserted or not at generation
getUncalced
()

public WindowTwoRecord
public short

Returns:

index of ExtendedFormatRecord associated with ColumnInfoRecord that includes the column index or the index of the default ExtendedFormatRecord (0xF)
getXFIndexForColAt
(short
the column index
columnIndex
)

get the index to the ExtendedFormatRecord "associated" with the column at specified 0-based index.

public void
groupColumnRange(int
group from this column (inclusive)
fromColumn
,
int
group to this column (inclusive)
toColumn
,
boolean
if true the group will be indented by one level, if false indenting will be removed by one level.
indent
)

Creates an outline group for the specified columns.

public void
groupRowRange(int fromRow, int toRow, boolean indent)

public boolean

Returns:

whether the column is hidden or not.
isColumnHidden
(int
column index
columnIndex
)

Get the hidden property for a given column.

public boolean

Returns:

whether formulas are displayed
isDisplayFormulas
()

Returns if formulas are displayed.

public boolean

Returns:

true if gridlines are displayed
isDisplayGridlines
()

public boolean

Returns:

whether RowColHeadings are displayed
isDisplayRowColHeadings
()

Returns if RowColHeadings are displayed.

public boolean

Returns:

true if gridlines are printed
isGridsPrinted
()

public boolean

Returns:

whether RowColHeadings are displayed
isPrintRowColHeadings
()

Returns if RowColHeadings are displayed.

public void
preSerialize()

Perform any work necessary before the sheet is about to be serialized.

private void
public void
removeMergedRegion(int index)

public void
removeRow(RowRecord
the row record to remove
row
)

Removes a row record This method is not loc sensitive, it resets loc to = dimsloc so no worries.

public void
removeValueRecord(int
- the row of the value record you wish to remove
row
,
CellValueRecordInterface
- a record supporting the CellValueRecordInterface.
col
)

remove a value record from the records array.

public void
replaceValueRecord(CellValueRecordInterface
- a record supporting the CellValueRecordInterface. this will replace the cell value with the same row and column. If there isn't one, one will be added.
newval
)

replace a value record from the records array.

public void
setActiveCellCol(short
the column index
col
)

Sets the active column

public void
setActiveCellRow(int
the row index
row
)

Sets the active row

private void
setColumn(int column, Short xfStyle, Integer width, Integer level, Boolean hidden, Boolean collapsed)

public void
setColumnGroupCollapsed(int columnNumber, boolean collapsed)

public void
setColumnHidden(int
- the column number
column
,
boolean
- whether the column is hidden or not
hidden
)

Set the hidden property for a given column.

public void
setColumnWidth(int
- the column number
column
,
int
(in units of 1/256th of a character width)
width
)

set the width for a given column in 1/256th of a character width units

public void
setDefaultColumnStyle(int column, int styleIndex)

public void
setDefaultColumnWidth(int
default column width
dcw
)

set the default column width for the sheet (if the columns do not define their own width)

public void
setDefaultRowHeight(short
the default row height
dch
)

set the default row height for the sheet (if the rows do not define their own height)

public void
setDimensions(int
the first row index
firstrow
,
short
the first column index
firstcol
,
int
the last row index
lastrow
,
short
the last column index
lastcol
)

Per an earlier reported bug in working with Andy Khan's excel read library.

public void
setDisplayFormulas(boolean
whether to show formulas or not
show
)

Sets whether the formulas are shown in a viewer.

public void
setDisplayGridlines(boolean
whether to show gridlines or not
show
)

Sets whether the gridlines are shown in a viewer.

public void
setDisplayRowColHeadings(boolean
whether to show RowColHeadings or not
show
)

Sets whether the RowColHeadings are shown in a viewer.

public void
setGridsPrinted(boolean
True if gridlines printed.
value
)

set whether gridlines printed or not.

public void
setLeftCol(short
the left column to show in desktop window pane
leftCol
)

Sets the left column to show in desktop window pane.

public void
setPrintGridlines(PrintGridlinesRecord
The new PrintGridlinesRecord for the sheet.
newPrintGridlines
)

Sets the PrintGridlinesRecord.

public void
setPrintHeaders(PrintHeadersRecord
The new PrintHeadersRecord for the sheet.
newPrintHeaders
)

Sets the PrintHeadersRecord.

public void
setPrintRowColHeadings(boolean
whether to show RowColHeadings or not
show
)

Sets whether the RowColHeadings are shown in a viewer.

public void
setSCLRecord(SCLRecord
The record to set.
sclRecord
)

Sets the SCL record or creates it in the correct place if it does not already exist.

public void
setSelected(boolean
True to select the sheet, false otherwise.
sel
)

Sets whether the sheet is selected

public void
public void
setTopRow(short topRow)

public void
setUncalced(boolean
whether an uncalced record must be inserted or not at generation
uncalced
)

private static void
public void
updateFormulasAfterCellShift(FormulaShifter
the formular shifter
shifter
,
int
the externSheet index of this sheet
externSheetIndex
)

Updates formulas in cells and conditional formats due to moving of cells

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait