public class Spreadsheet
extends com.vaadin.ui.AbstractComponent
implements com.vaadin.ui.HasComponents, com.vaadin.event.Action.Container, com.vaadin.ui.Component.Focusable
| Modifier and Type | Class and Description |
|---|---|
static interface |
Spreadsheet.CellDeletionHandler
An interface for handling cell deletion from user input.
|
static class |
Spreadsheet.CellValueChangeEvent
This event is fired when cell value changes.
|
static interface |
Spreadsheet.CellValueChangeListener
Used for knowing when a user has changed the cell value in Spreadsheet
UI.
|
static interface |
Spreadsheet.CellValueHandler
An interface for handling the edited cell value from user input.
|
static interface |
Spreadsheet.CommentAuthorProvider
This interface can be implemented to provide the comment author name set
to new comments in cells.
|
static class |
Spreadsheet.FormulaValueChangeEvent
This event is fired when the value of a cell referenced by a formula cell
changes making the formula value change
|
static interface |
Spreadsheet.FormulaValueChangeListener
Used for knowing when a cell referenced by a formula cell has changed in
the Spreadsheet UI making the formula value change
|
static interface |
Spreadsheet.HyperlinkCellClickHandler
An interface for handling clicks on cells that contain a hyperlink.
|
static class |
Spreadsheet.ProtectedEditEvent
An event that is fired when an attempt to modify a locked cell has been
made.
|
static interface |
Spreadsheet.ProtectedEditListener
A listener for when an attempt to modify a locked cell has been made.
|
static class |
Spreadsheet.RowHeaderDoubleClickEvent
This event is fired when the border of a row header is double clicked
|
static interface |
Spreadsheet.RowHeaderDoubleClickListener
Interface for listening a
Spreadsheet.RowHeaderDoubleClickEvent event |
static class |
Spreadsheet.SelectionChangeEvent
This event is fired when cell selection changes.
|
static interface |
Spreadsheet.SelectionChangeListener
Used for knowing when a user has changed the cell selection in any way.
|
static class |
Spreadsheet.SheetChangeEvent
An event that is fired to registered listeners when the selected sheet
has been changed.
|
static interface |
Spreadsheet.SheetChangeListener
A listener for when a sheet is selected.
|
static class |
Spreadsheet.ValueChangeEvent
This is a parent class for a value change events.
|
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListenercom.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listenercom.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener| Modifier and Type | Field and Description |
|---|---|
static String |
HIDE_FUNCTION_BAR_STYLE
This is a style which hides the top (address and formula) bar.
|
static String |
HIDE_TABSHEET_STYLE
This is a style which hides the bottom (sheet selection) bar.
|
protected String |
initialSheetSelection |
protected MergedRegionUtil.MergedRegionContainer |
mergedRegionContainer
Container for merged regions for the currently active sheet.
|
protected int |
mergedRegionCounter |
| Constructor and Description |
|---|
Spreadsheet()
Creates a new Spreadsheet component using the newer Excel version format
XSSFWorkbook. |
Spreadsheet(File file)
Creates a new Spreadsheet component and loads the given Excel file.
|
Spreadsheet(InputStream inputStream)
Creates a new Spreadsheet component based on the given input stream.
|
Spreadsheet(int defaultRowCount,
int defaultColumnCount)
Creates a new Spreadsheet component using the newer Excel version format
XSSFWorkbook. |
Spreadsheet(org.apache.poi.ss.usermodel.Workbook workbook)
Creates a new Spreadsheet component and loads the given Workbook.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addActionHandler(com.vaadin.event.Action.Handler actionHandler)
Adds an action handler to the spreadsheet that handles the event produced
by the context menu (right click) on cells and row and column headers.
|
com.vaadin.shared.Registration |
addCellValueChangeListener(Spreadsheet.CellValueChangeListener listener)
Adds the given CellValueChangeListener to this Spreadsheet.
|
com.vaadin.shared.Registration |
addFormulaValueChangeListener(Spreadsheet.FormulaValueChangeListener listener)
Adds the given FormulaValueChangeListener to this Spreadsheet.
|
void |
addMergedRegion(org.apache.poi.ss.util.CellRangeAddress region)
Merges the given cells.
|
void |
addMergedRegion(int row1,
int col1,
int row2,
int col2)
Merge cells.
|
void |
addMergedRegion(String selectionRange)
Merges cells.
|
void |
addProtectedEditListener(Spreadsheet.ProtectedEditListener listener)
Add listener for when an attempt to modify a locked cell has been made.
|
void |
addRowHeaderDoubleClickListener(Spreadsheet.RowHeaderDoubleClickListener listener)
adds a
Spreadsheet.RowHeaderDoubleClickListener to the Spreadsheet |
com.vaadin.shared.Registration |
addSelectionChangeListener(Spreadsheet.SelectionChangeListener listener)
Adds the given SelectionChangeListener to this Spreadsheet.
|
void |
addSheetChangeListener(Spreadsheet.SheetChangeListener listener)
Adds the given SheetChangeListener to this Spreadsheet.
|
void |
addSheetOverlay(SheetOverlayWrapper image) |
void |
attach() |
void |
autofitColumn(int columnIndex)
Sets the column to automatically adjust the column width to fit the
largest cell content within the column.
|
void |
beforeClientResponse(boolean initial) |
org.apache.poi.ss.usermodel.Cell |
createCell(int row,
int col,
Object value)
Create a new cell (or replace existing) with the given value, the type of
the value parameter will define the type of the cell.
|
protected CellValueManager |
createCellValueManager()
Override if there are desired changes or temporary bug fixes, but be
careful - this class should cache values for performance.
|
protected ConditionalFormatter |
createConditionalFormatter()
Override this method to provide your own
ConditionalFormatter
implementation. |
protected org.apache.poi.ss.util.CellRangeAddress |
createCorrectCellRangeAddress(int row1,
int col1,
int row2,
int col2)
Creates a CellRangeAddress from the given start and end coordinates.
|
protected org.apache.poi.ss.util.CellRangeAddress |
createCorrectCellRangeAddress(String addressString)
Creates a CellRangeAddress from the given cell address string.
|
org.apache.poi.ss.usermodel.Cell |
createFormulaCell(int row,
int col,
String formula)
Creates a new Formula type cell with the given formula.
|
void |
createFreezePane(int rowSplit,
int colSplit)
Creates or removes a freeze pane from the currently active sheet.
|
void |
createNewSheet(String sheetName,
int rows,
int columns)
Creates a new sheet as the last sheet and sets it as the active sheet.
|
protected SpreadsheetStyleFactory |
createSpreadsheetStyleFactory()
Override this method to provide your own
SpreadsheetStyleFactory
implementation. |
protected void |
customInit()
Implement this to perform custom initialization in subclasses.
|
void |
deleteCell(int row,
int col)
Deletes the cell from the sheet and the underlying POI model as well.
|
void |
deleteRows(int startRow,
int endRow)
Deletes rows.
|
void |
deleteSheet(int sheetIndex)
Deletes the sheet at the given index.
|
void |
deleteSheetWithPOIIndex(int poiSheetIndex)
Deletes the sheet with the given POI model index.
|
void |
deleteTable(SpreadsheetTable table)
Deletes the given table: removes it from "memory" (see
registerTable(SpreadsheetTable)), clears and removes all
possible filters (if table is a SpreadsheetFilterTable), and
clears all table pop-up buttons and content. |
void |
editCellComment(org.apache.poi.ss.util.CellReference cr)
Triggers editing of the cell comment in the given cell reference.
|
protected void |
fireEvent(EventObject event) |
void |
focus() |
org.apache.poi.ss.usermodel.Sheet |
getActiveSheet()
Note that modifications done directly with the POI
Sheet API will
not get automatically updated into the Spreadsheet component. |
int |
getActiveSheetIndex()
Returns the index of the currently active sheet among the visible sheets
( hidden or very hidden sheets not included).
|
int |
getActiveSheetPOIIndex()
Returns the POI model index of the currently active sheet (index among
all sheets including hidden and very hidden sheets).
|
org.apache.poi.ss.usermodel.Cell |
getCell(org.apache.poi.ss.util.CellReference cellReference)
Returns the Cell corresponding to the given reference.
|
org.apache.poi.ss.usermodel.Cell |
getCell(org.apache.poi.ss.util.CellReference cellReference,
org.apache.poi.ss.usermodel.Sheet sheet)
Returns the Cell corresponding to the given reference.
|
org.apache.poi.ss.usermodel.Cell |
getCell(int row,
int col)
Returns the Cell at the given coordinates.
|
org.apache.poi.ss.usermodel.Cell |
getCell(int row,
int col,
org.apache.poi.ss.usermodel.Sheet sheet)
Returns the Cell at the given coordinates.
|
org.apache.poi.ss.usermodel.Cell |
getCell(String cellAddress)
Returns the Cell at the given address.
|
org.apache.poi.ss.usermodel.Cell |
getCell(String sheetName,
int row,
int column)
Returns the Cell at the given coordinates.
|
Spreadsheet.CellDeletionHandler |
getCellDeletionHandler()
|
CellSelectionManager |
getCellSelectionManager()
Gets the CellSelectionManager for this Spreadsheet.
|
protected CellSelectionShifter |
getCellShifter()
Gets the CellShifter for this Spreadsheet.
|
String |
getCellValue(org.apache.poi.ss.usermodel.Cell cell)
Returns the formatted value for the given cell, using the
DataFormatter with the current locale. |
Spreadsheet.CellValueHandler |
getCellValueHandler()
|
CellValueManager |
getCellValueManager()
Gets the CellValueManager for this Spreadsheet.
|
int |
getColBufferSize()
The column buffer size determines the amount of content rendered outside
the left and right edges of the visible cell area, for smoother
scrolling.
|
int |
getColumns()
Get the number of columns in the currently active sheet, or if
setMaxColumns(int) has been used, the current number of columns
the component shows (not the amount of columns in the actual sheet in the
POI model). |
Spreadsheet.CommentAuthorProvider |
getCommentAuthorProvider()
Gets the CommentAuthorProvider currently set to this Spreadsheet.
|
ConditionalFormatter |
getConditionalFormatter()
Gets the ConditionalFormatter
|
org.apache.poi.ss.formula.ConditionalFormattingEvaluator |
getConditionalFormattingEvaluator()
POI, as of 4.0.0, now accepts this as an argument to formula evaluation.
|
ContextMenuManager |
getContextMenuManager()
Gets the ContextMenuManager for this Spreadsheet.
|
protected Collection<String> |
getCustomAttributes() |
org.apache.poi.ss.usermodel.DataFormatter |
getDataFormatter()
Gets the current DataFormatter.
|
int |
getDefaultColumnCount()
Gets the default column count for new sheets.
|
int |
getDefaultColumnWidth()
Gets the default column width for the currently active sheet.
|
String |
getDefaultPercentageFormat()
Returns the formatting string that is used when a user enters percentages
into the Spreadsheet.
|
int |
getDefaultRowCount()
Gets the default row count for new sheets.
|
float |
getDefaultRowHeight()
Gets the default row height in points.
|
int |
getFirstColumn()
Returns the first visible column in the main scroll area (NOT freeze
pane)
|
int |
getFirstRow()
Returns the first visible row in the scroll area (not freeze pane)
|
org.apache.poi.ss.usermodel.FormulaEvaluator |
getFormulaEvaluator() |
Spreadsheet.HyperlinkCellClickHandler |
getHyperlinkCellClickHandler()
|
int |
getLastColumn()
Returns the last visible column in the main scroll area (NOT freeze pane)
|
int |
getLastFrozenColumn()
Returns the index the last frozen column (last column in left freeze
pane).
|
int |
getLastFrozenRow()
Returns the index the last frozen row (last row in top freeze pane).
|
int |
getLastRow()
Returns the last visible row in the main scroll area (NOT freeze pane)
|
protected MergedRegionUtil.MergedRegionContainer |
getMergedRegionContainer()
Gets the MergedRegionContainer for this Spreadsheet.
|
int |
getMinimumRowHeightForComponents()
Get the minimum row heigth in points for the rows that contain custom
components
|
int |
getNumberOfSheets()
Returns the total number of sheets in the workbook (includes hidden and
very hidden sheets).
|
int |
getNumberOfVisibleSheets()
Returns the number of currently visible sheets in the component.
|
int |
getRowBufferSize()
The row buffer size determines the amount of content rendered outside the
top and bottom edges of the visible cell area, for smoother scrolling.
|
int |
getRows()
Get the number of rows in the currently active sheet, or if
setMaxRows(int) has been used, the current number of rows the
component shows (not the amount of rows in the actual sheet in the POI
model). |
protected SpreadsheetClientRpc |
getRpcProxy()
Gets the RPC proxy for communication to the client side.
|
org.apache.poi.ss.util.CellReference |
getSelectedCellReference()
Gets a reference to the current single selected cell.
|
Set<org.apache.poi.ss.util.CellReference> |
getSelectedCellReferences()
Gets all the currently selected cells.
|
SpreadsheetComponentFactory |
getSpreadsheetComponentFactory()
Gets the current SpreadsheetComponentFactory.
|
protected SpreadsheetHandlerImpl |
getSpreadsheetHandler() |
SpreadsheetHistoryManager |
getSpreadsheetHistoryManager()
Gets the SpreadsheetHistoryManager for this Spreadsheet.
|
SpreadsheetStyleFactory |
getSpreadsheetStyleFactory()
Gets the currently used style factory for this Spreadsheet.
|
protected SpreadsheetState |
getState() |
protected SpreadsheetState |
getState(boolean markAsDirty) |
String |
getStatusLabelValue()
Gets the content of the status label
|
int |
getTabIndex() |
HashSet<SpreadsheetTable> |
getTables()
Gets all the tables that have been registered to this Spreadsheet.
|
List<SpreadsheetTable> |
getTablesForActiveSheet()
Gets the tables that belong to the currently active sheet (
getActiveSheet()). |
String[] |
getVisibleSheetNames()
Returns an array containing the names of the currently visible sheets.
|
int |
getVisibleSheetPOIIndex(int visibleSheetIndex)
Returns POI model based index for the given Spreadsheet sheet index.
|
org.apache.poi.ss.usermodel.Workbook |
getWorkbook()
Note that modifications done directly with the POI
Workbook API
will not get automatically updated into the Spreadsheet component. |
boolean |
isActiveSheetProtected()
Gets the protection state of the current sheet.
|
protected boolean |
isCellEditable(org.apache.poi.ss.usermodel.Cell cell)
Gets the editable state of the given cell.
|
boolean |
isCellHidden(org.apache.poi.ss.usermodel.Cell cell)
Gets the visibility state of the given cell.
|
boolean |
isCellLocked(org.apache.poi.ss.usermodel.Cell cell)
Gets the locked state of the given cell.
|
boolean |
isChartsEnabled()
Returns true if embedded charts are displayed
|
boolean |
isColumnHidden(int columnIndex)
Gets the visibility state of the given column.
|
boolean |
isFunctionBarVisible()
Gets the visibility of the top function bar.
|
boolean |
isGridlinesVisible()
Gets grid line visibility for the currently active sheet.
|
protected boolean |
isRangeEditable(org.apache.poi.ss.util.CellRangeAddress cellRangeAddress)
Tells whether the given cell range is editable or not.
|
protected boolean |
isRangeEditable(int row1,
int col1,
int row2,
int col2)
Determines if the given cell range is editable or not.
|
boolean |
isReportStyle()
Gets the state of the report style.
|
boolean |
isRerenderPending()
Returns true if the component is being fully re-rendered after this
round-trip (sheet change etc.)
|
boolean |
isRowColHeadingsVisible()
Gets row and column heading visibility for the currently active sheet.
|
boolean |
isRowHidden(int rowIndex)
Gets the visibility state of the given row.
|
boolean |
isSheetProtected(int poiSheetIndex)
Gets the protection state of the sheet at the given POI index.
|
boolean |
isSheetSelectionBarVisible()
Gets the visibility of the bottom sheet selection bar.
|
Iterator<com.vaadin.ui.Component> |
iterator() |
protected void |
levelHeaderClicked(boolean isCols,
int level)
Called when a grouping level header is clicked
|
protected void |
loadCells(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
Sends data of the given cell area to client side.
|
protected void |
loadCustomEditorOnSelectedCell()
This method should be always called when the selected cell has changed so
proper actions can be triggered for possible custom component inside the
cell.
|
void |
markCellAsDeleted(org.apache.poi.ss.usermodel.Cell cell,
boolean cellStyleUpdated)
Marks the cell as deleted.
|
protected void |
onColumnAutofit(int columnIndex)
This method is called when column auto-fit has been initiated from the
browser by double-clicking the border of the target column header.
|
protected void |
onConnectorInit()
This is called when the client-side connector has been initialized.
|
protected void |
onNewSheetCreated(int scrollLeft,
int scrollTop)
This method is called when the creation of a new sheet has been
requested.
|
protected void |
onRowHeaderDoubleClick(int rowIndex)
This method is called when rowIndex auto-fit has been initiated from the
browser by double-clicking the border of the target rowIndex header.
|
protected void |
onSheetRename(int sheetIndex,
String sheetName)
This method is called when a request to rename a sheet has been made.
|
protected void |
onSheetScroll(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
This method is called when the sheet is scrolled.
|
protected void |
onSheetSelected(int tabIndex,
int scrollLeft,
int scrollTop)
This method will be called when a selected sheet change is requested.
|
void |
read(File file)
Reinitializes the component from the given Excel file.
|
void |
read(InputStream inputStream)
Reinitializes the component from the given input stream.
|
void |
readDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext) |
void |
refreshAllCellValues()
Forces recalculation and update to the client side for values of all of
the sheet's cells.
|
void |
refreshCells(org.apache.poi.ss.usermodel.Cell... cells)
Refreshes the given cell(s).
|
void |
refreshCells(Collection<org.apache.poi.ss.usermodel.Cell> cells)
Refreshes the given cell(s).
|
void |
registerTable(SpreadsheetTable table)
Registers the given table to this Spreadsheet, meaning that this table
will be reloaded when the active sheet changes to the sheet containing
the table.
|
void |
reload()
Reloads all data from the current spreadsheet and performs a full
re-render.
|
protected void |
reloadActiveSheetData()
Clears and reloads all data related to the currently active sheet.
|
void |
reloadActiveSheetStyles()
Reloads all the styles for the currently active sheet.
|
void |
reloadAllMergedRegions()
Discards all current merged regions for the sheet and reloads them from
the POI model.
|
void |
reloadVisibleCellContents()
Call this to force the spreadsheet to reload the currently viewed cell
contents.
|
void |
removeActionHandler(com.vaadin.event.Action.Handler actionHandler) |
void |
removeCellValueChangeListener(Spreadsheet.CellValueChangeListener listener)
Deprecated.
as of 3.1.0 use the
Registration.remove() method of
the Registration object returned from the
addCellValueChangeListener(CellValueChangeListener)
method |
void |
removeDefaultActionHandler()
Removes the spreadsheet's
SpreadsheetDefaultActionHandler added
on init() |
void |
removeFreezePane()
Removes the freeze pane from the currently active sheet if one is
present.
|
void |
removeMergedRegion(int index)
Removes a merged region with the given index.
|
void |
removeProtectedEditListener(Spreadsheet.ProtectedEditListener listener)
Deprecated.
as of 3.1.0 use the
Registration.remove() method of
the Registration object returned from the
addProtectedEditListener(ProtectedEditListener)
method |
void |
removeSelectionChangeListener(Spreadsheet.SelectionChangeListener listener)
Deprecated.
as of 3.1.0 use the
Registration.remove() method of
the Registration object returned from the
addSelectionChangeListener(SelectionChangeListener)
method |
void |
removeSheetChangeListener(Spreadsheet.SheetChangeListener listener)
Deprecated.
as of 3.1.0 use the
Registration.remove() method of
the Registration object returned from the
addSheetChangeListener(SheetChangeListener) method |
void |
reset()
Disposes the current
Workbook, if any, and loads a new empty XSLX
Workbook. |
void |
setActiveSheetIndex(int sheetIndex)
Sets the currently active sheet within the sheets that are visible.
|
void |
setActiveSheetProtected(String password)
Sets the protection enabled with the given password for the currently
active sheet.
|
void |
setActiveSheetWithPOIIndex(int sheetIndex)
Sets the currently active sheet.
|
void |
setCellDeletionHandler(Spreadsheet.CellDeletionHandler customCellDeletionHandler)
Sets the
Spreadsheet.CellDeletionHandler for this component (not
workbook/sheet specific). |
void |
setCellValueHandler(Spreadsheet.CellValueHandler customCellValueHandler)
Sets the
Spreadsheet.CellValueHandler for this component (not workbook/sheet
specific). |
void |
setChartsEnabled(boolean chartsEnabled)
Use this method to define whether embedded charts should be displayed in
the spreadsheet or not.
|
void |
setColBufferSize(int colBufferInPixels)
Sets the column buffer size.
|
void |
setColumnHidden(int columnIndex,
boolean hidden)
Hides or shows the given column, see
Sheet.setColumnHidden(int, boolean). |
void |
setColumnWidth(int index,
int width)
Sets the column width in pixels (using conversion) for the currently
active sheet.
|
void |
setCommentAuthorProvider(Spreadsheet.CommentAuthorProvider commentAuthorProvider)
Sets the given CommentAuthorProvider to this Spreadsheet.
|
void |
setDefaultColumnCount(int defaultColumnCount)
Sets the default column count for new sheets.
|
void |
setDefaultColumnWidth(int widthPX)
Sets the default column width in pixels that the component uses, this
doesn't change the default column width of the underlying sheet, returned
by
getActiveSheet() and Sheet.getDefaultColumnWidth(). |
void |
setDefaultPercentageFormat(String defaultPercentageFormat)
Sets the formatting string that is used when a user enters percentages
into the Spreadsheet.
|
void |
setDefaultRowCount(int defaultRowCount)
Sets the default row count for new sheets.
|
void |
setDefaultRowHeight(float heightPT)
Sets the default row height in points for this Spreadsheet and the
currently active sheet, returned by
getActiveSheet(). |
void |
setFunctionBarVisible(boolean functionBarVisible)
Sets the visibility of the top function bar.
|
void |
setGridlinesVisible(boolean visible)
Sets grid line visibility for the currently active sheet.
|
protected void |
setGroupingCollapsed(boolean isCols,
int index,
boolean collapsed)
Controls if a column group is collapsed or not.
|
void |
setHyperlinkCellClickHandler(Spreadsheet.HyperlinkCellClickHandler handler)
Sets the
Spreadsheet.HyperlinkCellClickHandler for this component (not
workbook/sheet specific). |
void |
setInvalidFormulaErrorMessage(String invalidFormulaErrorMessage) |
void |
setLocale(Locale locale) |
void |
setMaxColumns(int cols)
Set the number of columns shown for the current sheet.
|
void |
setMaxRows(int rows)
Set the number of rows shown for the current sheet.
|
void |
setMinimumRowHeightForComponents(int minimumRowHeightForComponents)
Set the minimum row heigth in points for the rows that contain custom
components.
|
void |
setPopup(org.apache.poi.ss.util.CellReference cellReference,
PopupButton popupButton)
Sets a pop-up button to the given cell in the currently active sheet.
|
void |
setPopup(int row,
int col,
PopupButton popupButton)
Sets a pop-up button to the given cell in the currently active sheet.
|
void |
setPopup(String cellAddress,
PopupButton popupButton)
Sets a pop-up button to the given cell in the currently active sheet.
|
void |
setReportStyle(boolean reportStyle)
Enables or disables the report style.
|
protected void |
setResource(String key,
com.vaadin.server.Resource resource) |
void |
setRowBufferSize(int rowBufferInPixels)
Sets the row buffer size.
|
void |
setRowColHeadingsVisible(boolean visible)
Sets row and column heading visibility for the currently active sheet.
|
void |
setRowHeight(int index,
float height)
Sets the row height for currently active sheet.
|
void |
setRowHidden(int rowIndex,
boolean hidden)
Hides or shows the given row, see
Row.setZeroHeight(boolean). |
void |
setSelection(int row,
int col)
Selects the cell at the given coordinates
|
void |
setSelection(String selectionRange)
Selects the cell(s) at the given coordinates
Coordinates can be simple "A1" style addresses or ranges, named ranges,
or a formula.
|
void |
setSelectionRange(int row1,
int col1,
int row2,
int col2)
Selects the given range, using the cell at row1 and col1 as an anchor.
|
void |
setSheetHidden(int sheetPOIIndex,
int hidden)
Deprecated.
|
void |
setSheetHidden(int sheetPOIIndex,
org.apache.poi.ss.usermodel.SheetVisibility visibility)
See
Workbook.setSheetHidden(int, boolean). |
void |
setSheetMaxSize(int rows,
int cols)
Does
setMaxColumns(int) and setMaxRows(int) in one
method. |
void |
setSheetName(int sheetIndex,
String sheetName)
Sets a name for the sheet at the given visible sheet index.
|
void |
setSheetNameWithPOIIndex(int sheetIndex,
String sheetName)
Sets a name for the sheet at the given POI model index.
|
void |
setSheetProtected(int sheetPOIIndex,
String password)
Sets the protection enabled with the given password for the sheet at the
given index.
|
void |
setSheetSelectionBarVisible(boolean sheetSelectionBarVisible)
Sets the visibility of the bottom sheet selection bar.
|
void |
setSpreadsheetComponentFactory(SpreadsheetComponentFactory customComponentFactory)
Set a new component factory for this Spreadsheet.
|
void |
setStatusLabelValue(String value)
Sets the content of the status label.
|
void |
setTabIndex(int tabIndex) |
void |
setWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
Reloads the component with the given Workbook.
|
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 |
unregisterTable(SpreadsheetTable table)
Unregisters the given table from this Spreadsheet - it will no longer get
reloaded when the sheet is changed back to the sheet containing the
table.
|
void |
write(OutputStream outputStream)
Exports current spreadsheet as an output stream.
|
File |
write(String fileName)
Exports current spreadsheet into a File with the given name.
|
void |
writeDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext) |
addContextClickListener, addListener, addShortcutListener, addStyleName, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isOrHasAncestor, isReadOnly, isRequiredIndicatorVisible, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setDescription, setEnabled, setHeight, setHeight, setHeightFull, setHeightUndefined, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setRequiredIndicatorVisible, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth, setWidthFull, setWidthUndefinedaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitforEach, spliteratoraddListener, addStyleName, addStyleNames, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, removeListener, removeStyleName, removeStyleNames, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setStyleName, setStyleName, setVisibleaddAttachListener, addDetachListener, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlerpublic static final String HIDE_FUNCTION_BAR_STYLE
public static final String HIDE_TABSHEET_STYLE
protected int mergedRegionCounter
protected String initialSheetSelection
protected final MergedRegionUtil.MergedRegionContainer mergedRegionContainer
public Spreadsheet()
XSSFWorkbook. Also creates one sheet using the default row
SpreadsheetFactory.DEFAULT_ROWS and column
SpreadsheetFactory.DEFAULT_COLUMNS counts.public Spreadsheet(int defaultRowCount,
int defaultColumnCount)
XSSFWorkbook. Also creates one sheet using the given row and
column counts. These counts will also be set as default for any new
sheets created later.defaultRowCount - Default row count for new sheetsdefaultColumnCount - Default column count for new sheetspublic Spreadsheet(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - Workbook to loadpublic Spreadsheet(File file) throws IOException
file - Excel fileIOException - If file has invalid format or there is no access to the filepublic Spreadsheet(InputStream inputStream) throws IOException
inputStream - Stream that provides Excel-formatted data.IOException - If there is an error handling the stream, or if the data is
in an invalid format.protected SpreadsheetHandlerImpl getSpreadsheetHandler()
protected CellValueManager createCellValueManager()
protected void customInit()
public void addActionHandler(com.vaadin.event.Action.Handler actionHandler)
The parameters on the
Action.Handler.handleAction(Action, Object, Object) and
Action.Handler.getActions(Object, Object) depend on the actual target of
the right click.
The second parameter (sender) on
Action.Handler.getActions(Object, Object) is always the spreadsheet
component. In case of a cell, the first parameter (target) on contains
the latest Spreadsheet.SelectionChangeEvent for the spreadsheet. In case of a
row or a column header, the first parameter (target) is a
CellRangeAddress. To distinct between column / row header, you
can use CellRangeAddressBase.isFullColumnRange() and
CellRangeAddressBase.isFullRowRange().
Similarly for Action.Handler.handleAction(Action, Object, Object) the
second parameter (sender) is always the spreadsheet component. The third
parameter (target) is the latest Spreadsheet.SelectionChangeEvent for the
spreadsheet, or the CellRangeAddress defining the selected row /
column header.
addActionHandler in interface com.vaadin.event.Action.Containerpublic void removeDefaultActionHandler()
SpreadsheetDefaultActionHandler added
on init()public void removeActionHandler(com.vaadin.event.Action.Handler actionHandler)
removeActionHandler in interface com.vaadin.event.Action.Containerpublic void setCellValueHandler(Spreadsheet.CellValueHandler customCellValueHandler)
Spreadsheet.CellValueHandler for this component (not workbook/sheet
specific). It is called when a cell's value has been updated by the user
by using the spreadsheet component's default editor (text input).customCellValueHandler - New handler or null if none should be usedpublic Spreadsheet.CellValueHandler getCellValueHandler()
Spreadsheet.CellValueHandler for this component or
null if none has been setpublic void setCellDeletionHandler(Spreadsheet.CellDeletionHandler customCellDeletionHandler)
Spreadsheet.CellDeletionHandler for this component (not
workbook/sheet specific). It is called when a cell has been deleted by
the user.customCellDeletionHandler - New handler or null if none should be usedpublic Spreadsheet.CellDeletionHandler getCellDeletionHandler()
Spreadsheet.CellDeletionHandler for this component or
null if none has been setpublic void setHyperlinkCellClickHandler(Spreadsheet.HyperlinkCellClickHandler handler)
Spreadsheet.HyperlinkCellClickHandler for this component (not
workbook/sheet specific). Called when the user clicks a cell that is a
hyperlink or uses the hyperlink function.handler - new handler or null if none should be usedSpreadsheet.HyperlinkCellClickHandler,
DefaultHyperlinkCellClickHandlerpublic Spreadsheet.HyperlinkCellClickHandler getHyperlinkCellClickHandler()
Spreadsheet.HyperlinkCellClickHandler for this component
or null if none has been setpublic ContextMenuManager getContextMenuManager()
public CellSelectionManager getCellSelectionManager()
public CellValueManager getCellValueManager()
protected CellSelectionShifter getCellShifter()
public SpreadsheetHistoryManager getSpreadsheetHistoryManager()
protected MergedRegionUtil.MergedRegionContainer getMergedRegionContainer()
public int getFirstColumn()
public int getLastColumn()
public int getFirstRow()
public int getLastRow()
public int getLastFrozenRow()
public int getLastFrozenColumn()
public boolean isChartsEnabled()
true if the charts are enabled, false otherwisesetChartsEnabled(boolean)public void setChartsEnabled(boolean chartsEnabled)
chartsEnabled - public boolean isRerenderPending()
protected void fireEvent(EventObject event)
fireEvent in class com.vaadin.server.AbstractClientConnectorprotected void onSheetScroll(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
firstRow - Index of first visible row after the scroll, 1-basedfirstColumn - Index of first visible column after the scroll, 1-basedlastRow - Index of last visible row after the scroll, 1-basedlastColumn - Index of first visible column after the scroll, 1-basedprotected boolean isRangeEditable(org.apache.poi.ss.util.CellRangeAddress cellRangeAddress)
cellRangeAddress - Cell range to testprotected boolean isRangeEditable(int row1,
int col1,
int row2,
int col2)
row1 - Index of starting row, 0-basedcol1 - Index of starting column, 0-basedrow2 - Index of ending row, 0-basedcol2 - Index of ending column, 0-basedprotected org.apache.poi.ss.util.CellRangeAddress createCorrectCellRangeAddress(String addressString)
addressString - Cell address string, e.g. "B3:C5"protected org.apache.poi.ss.util.CellRangeAddress createCorrectCellRangeAddress(int row1,
int col1,
int row2,
int col2)
row1 - Index of the starting row, 1-basedcol1 - Index of the starting column, 1-basedrow2 - Index of the ending row, 1-basedcol2 - Index of the ending column, 1-basedprotected SpreadsheetState getState()
getState in class com.vaadin.ui.AbstractComponentprotected SpreadsheetState getState(boolean markAsDirty)
getState in class com.vaadin.ui.AbstractComponentpublic void setLocale(Locale locale)
setLocale in class com.vaadin.ui.AbstractComponentpublic void attach()
attach in interface com.vaadin.server.ClientConnectorattach in interface com.vaadin.ui.Componentattach in class com.vaadin.ui.AbstractComponentpublic void setSheetHidden(int sheetPOIIndex,
org.apache.poi.ss.usermodel.SheetVisibility visibility)
throws IllegalArgumentException
Workbook.setSheetHidden(int, boolean).
Gets the Workbook with getWorkbook() and uses its API to access
status on currently visible/hidden/very hidden sheets.
If the currently active sheet is set hidden, another sheet is set as
active sheet automatically. At least one sheet should be always visible.
sheetPOIIndex - Index of the target sheet within the POI model, 0-basedvisibility - Visibility state to set: visible, hidden, very hidden.IllegalArgumentException - If the index or state is invalid, or if trying to hide the
only visible sheet.@Deprecated public void setSheetHidden(int sheetPOIIndex, int hidden) throws IllegalArgumentException
setSheetHidden(int, SheetVisibility)Workbook.setSheetHidden(int, boolean).
Gets the Workbook with getWorkbook() and uses its API to access
status on currently visible/hidden/very hidden sheets.
If the currently active sheet is set hidden, another sheet is set as
active sheet automatically. At least one sheet should be always visible.
hidden - Visibility state to set: 0-visible, 1-hidden, 2-very hidden.sheetPOIIndex - Index of the target sheet within the POI model, 0-basedIllegalArgumentException - If the index or state is invalid, or if trying to hide the
only visible sheet.public String[] getVisibleSheetNames()
To get all of the current Workbook's sheet names, you should
access the POI API with getWorkbook().
public void setSheetName(int sheetIndex,
String sheetName)
throws IllegalArgumentException
sheetIndex - Index of the target sheet among the visible sheets, 0-basedsheetName - New sheet name. Not null, empty nor longer than 31 characters.
Must be unique within the Workbook.IllegalArgumentException - If the index is invalid, or if the sheet name is invalid. See
WorkbookUtil.validateSheetName(String).public void setSheetNameWithPOIIndex(int sheetIndex,
String sheetName)
throws IllegalArgumentException
sheetIndex - Index of the target sheet within the POI model, 0-basedsheetName - New sheet name. Not null, empty nor longer than 31 characters.
Must be unique within the Workbook.IllegalArgumentException - If the index is invalid, or if the sheet name is invalid. See
WorkbookUtil.validateSheetName(String).public void setSheetProtected(int sheetPOIIndex,
String password)
null password removes the protection.sheetPOIIndex - Index of the target sheet within the POI model, 0-basedpassword - The password to set for the protection. Pass null
to remove the protection.public void setActiveSheetProtected(String password)
null password removes the protection.password - The password to set for the protection. Pass null
to remove the protection.public void createNewSheet(String sheetName, int rows, int columns) throws IllegalArgumentException
Workbook.createSheet().sheetName - Can be null, but not empty nor longer than 31 characters. Must
be unique within the Workbook.rows - Number of rows the sheet should havecolumns - Number of columns the sheet should haveIllegalArgumentException - If the sheet name is empty or over 31 characters long or not
unique.public void deleteSheetWithPOIIndex(int poiSheetIndex)
throws IllegalArgumentException
poiSheetIndex - POI model index of the sheet to delete, 0-based, max value
Workbook.getNumberOfSheets() -1.IllegalArgumentException - In case there is only one visible sheet, or if the index is
invalid.public void deleteSheet(int sheetIndex)
throws IllegalArgumentException
sheetIndex - Index of the sheet to delete among the visible sheets,
0-based, maximum value getNumberOfVisibleSheets() -1.IllegalArgumentException - In case there is only one visible sheet, or if the given
index is invalid.public int getNumberOfVisibleSheets()
public int getNumberOfSheets()
public int getActiveSheetIndex()
public int getActiveSheetPOIIndex()
public void setActiveSheetIndex(int sheetIndex)
throws IllegalArgumentException
sheetIndex - Index of the target sheet (among the visible sheets), 0-basedIllegalArgumentException - If the index is invalidpublic void setActiveSheetWithPOIIndex(int sheetIndex)
throws IllegalArgumentException
sheetIndex - Index of sheet in the POI model (contains all sheets), 0-basedIllegalArgumentException - If the index is invalid, or if the sheet at the given index
is hidden or very hidden.protected void onSheetSelected(int tabIndex,
int scrollLeft,
int scrollTop)
tabIndex - Index of the sheet to select.scrollLeft - Current horizontal scroll positionscrollTop - Current vertical scroll positionprotected void onNewSheetCreated(int scrollLeft,
int scrollTop)
scrollLeft - Current horizontal scroll positionscrollTop - Current vertical scroll positionprotected void onSheetRename(int sheetIndex,
String sheetName)
sheetIndex - Index of the sheet to rename (among visible sheets).sheetName - New name for the sheet.public int getColumns()
setMaxColumns(int) has been used, the current number of columns
the component shows (not the amount of columns in the actual sheet in the
POI model).public int getRows()
setMaxRows(int) has been used, the current number of rows the
component shows (not the amount of rows in the actual sheet in the POI
model).public org.apache.poi.ss.usermodel.DataFormatter getDataFormatter()
public org.apache.poi.ss.usermodel.Cell getCell(String cellAddress)
refreshCells(Cell...) AFTER ALL UPDATES (value, type,
formatting or style) to mark the cell as "dirty".cellAddress - Address of the Cell to return, e.g. "A3"public org.apache.poi.ss.usermodel.Cell getCell(int row,
int col)
refreshCells(Cell...) AFTER ALL UPDATES
(value, type, formatting or style) to mark the cell as "dirty".row - Row index of the cell to return, 0-basedcol - Column index of the cell to return, 0-basedpublic org.apache.poi.ss.usermodel.Cell getCell(int row,
int col,
org.apache.poi.ss.usermodel.Sheet sheet)
refreshCells(Cell...) AFTER ALL UPDATES
(value, type, formatting or style) to mark the cell as "dirty".row - Row index of the cell to return, 0-basedcol - Column index of the cell to return, 0-basedsheet - Sheet of the cellpublic org.apache.poi.ss.usermodel.Cell getCell(org.apache.poi.ss.util.CellReference cellReference)
refreshCells(Cell...) AFTER ALL
UPDATES (value, type, formatting or style) to mark the cell as "dirty".cellReference - Reference to the cell to returnpublic org.apache.poi.ss.usermodel.Cell getCell(String sheetName, int row, int column)
refreshCells(Cell...) AFTER ALL UPDATES
(value, type, formatting or style) to mark the cell as "dirty".sheetName - Name of the sheet the cell is on, or current sheet if nullrow - Row index of the cell to return, 0-basedcolumn - Column index of the cell to return, 0-basedpublic org.apache.poi.ss.usermodel.Cell getCell(org.apache.poi.ss.util.CellReference cellReference,
org.apache.poi.ss.usermodel.Sheet sheet)
refreshCells(Cell...) AFTER ALL
UPDATES (value, type, formatting or style) to mark the cell as "dirty".cellReference - Reference to the cell to returnsheet - Sheet of the cellpublic void deleteCell(int row,
int col)
row - Row index of the cell to delete, 0-basedcol - Column index of the cell to delete, 0-basedpublic void refreshCells(org.apache.poi.ss.usermodel.Cell... cells)
cells - Cell(s) to updatepublic void refreshCells(Collection<org.apache.poi.ss.usermodel.Cell> cells)
cells - A Collection of Cells to updatepublic void markCellAsDeleted(org.apache.poi.ss.usermodel.Cell cell,
boolean cellStyleUpdated)
Workbook using POI API.cellStyleUpdated - True if the cell style has changedcell - The cell that has been deleted.public org.apache.poi.ss.usermodel.Cell createFormulaCell(int row,
int col,
String formula)
throws IllegalArgumentException
refreshCells(Cell...) or
refreshAllCellValues() to make sure client side is updated.row - Row index of the new cell, 0-basedcol - Column index of the new cell, 0-basedformula - The formula to set to the new cell (should NOT start with "="
nor "+")IllegalArgumentException - If columnIndex < 0 or greater than the maximum number of
supported columns (255 for *.xls, 1048576 for *.xlsx)public org.apache.poi.ss.usermodel.Cell createCell(int row,
int col,
Object value)
throws IllegalArgumentException
Object.toString() will be given
as the cell value.
For formula cells, use createFormulaCell(int, int, String).
After all editing is done, call refreshCells(Cell...) or
refreshAllCellValues() to make sure the client side is updated.row - Row index of the new cell, 0-basedcol - Column index of the new cell, 0-basedvalue - Object representing the type and value of the CellIllegalArgumentException - If columnIndex < 0 or greater than the maximum number of
supported columns (255 for *.xls, 1048576 for *.xlsx)public void refreshAllCellValues()
refreshCells(Cell...) when
cell styles change.public void setMaxColumns(int cols)
cols - New maximum column count.public void setMaxRows(int rows)
rows - New maximum row count.public void setSheetMaxSize(int rows,
int cols)
setMaxColumns(int) and setMaxRows(int) in one
method.rows - Maximum row countcols - Maximum column countpublic int getDefaultColumnWidth()
getActiveSheet()) default
column width (Sheet getDefaultColumnWidth()).public void setDefaultColumnWidth(int widthPX)
getActiveSheet() and Sheet.getDefaultColumnWidth().widthPX - The default column width in pixelspublic float getDefaultRowHeight()
Sheet.getDefaultRowHeightInPoints() for the currently active
sheet getActiveSheet().public void setDefaultRowHeight(float heightPT)
getActiveSheet().heightPT - New default row height in points.protected void onRowHeaderDoubleClick(int rowIndex)
rowIndex - Index of the target rowIndex, 0-basedpublic void addRowHeaderDoubleClickListener(Spreadsheet.RowHeaderDoubleClickListener listener)
Spreadsheet.RowHeaderDoubleClickListener to the Spreadsheetlistener - The listener to addprotected void onColumnAutofit(int columnIndex)
columnIndex - Index of the target column, 0-basedpublic void autofitColumn(int columnIndex)
Sheet.autoSizeColumn(int).
This does not take into account cells that have custom Vaadin components inside them.
columnIndex - Index of the target column, 0-basedpublic void shiftRows(int startRow,
int endRow,
int n)
If you are adding / deleting rows, you might want to change the number of
visible rows rendered getRows() with setMaxRows(int).
See Sheet.shiftRows(int, int, int).
startRow - The first row to shift, 0-basedendRow - The last row to shift, 0-basedn - Number of rows to shift, positive numbers shift down, negative
numbers shift up.public void shiftRows(int startRow,
int endRow,
int n,
boolean copyRowHeight,
boolean resetOriginalRowHeight)
If you are adding / deleting rows, you might want to change the number of
visible rows rendered getRows() with setMaxRows(int).
See Sheet.shiftRows(int, int, int, boolean, boolean).
startRow - The first row to shift, 0-basedendRow - The last row to shift, 0-basedn - Number of rows to shift, positive numbers shift down, negative
numbers shift up.copyRowHeight - True to copy the row height during the shiftresetOriginalRowHeight - True to set the original row's height to the defaultpublic org.apache.poi.ss.usermodel.FormulaEvaluator getFormulaEvaluator()
FormulaEvaluator instance.public org.apache.poi.ss.formula.ConditionalFormattingEvaluator getConditionalFormattingEvaluator()
ConditionalFormattingEvaluator instance.public void deleteRows(int startRow,
int endRow)
Sheet.removeRow(Row). Removes all row content,
deletes cells and resets the sheet size.
Does not shift rows up (!) - use
shiftRows(int, int, int, boolean, boolean) for that.startRow - Index of the starting row, 0-basedendRow - Index of the ending row, 0-basedpublic void addMergedRegion(String selectionRange)
Sheet.addMergedRegion(CellRangeAddress).selectionRange - The cell range to merge, e.g. "B3:C5"public void addMergedRegion(int row1,
int col1,
int row2,
int col2)
Sheet.addMergedRegion(CellRangeAddress).row1 - Index of the starting row of the merged region, 0-basedcol1 - Index of the starting column of the merged region, 0-basedrow2 - Index of the ending row of the merged region, 0-basedcol2 - Index of the ending column of the merged region, 0-basedpublic void addMergedRegion(org.apache.poi.ss.util.CellRangeAddress region)
throws IllegalArgumentException
Sheet.addMergedRegion(CellRangeAddress).
If another existing merged region is completely inside the given range,
it is removed. If another existing region either encloses or overlaps the
given range, an error is thrown. See
CellRangeUtil.intersect(CellRangeAddress, CellRangeAddress).
Note: POI doesn't seem to update the cells that are "removed" due to the merge - the values for those cells still exist and continue being used in possible formulas. If you need to make sure those values are removed, just delete the cells before creating the merged region.
If the added region affects the currently selected cell, a new
Spreadsheet.SelectionChangeEvent is fired.
region - The range of cells to mergeIllegalArgumentException - If the given region overlaps with or encloses another
existing region within the sheet.public void removeMergedRegion(int index)
getActiveSheet() and Sheet.getMergedRegion(int) and
Sheet.getNumMergedRegions().
Note that in POI after removing a merged region at index n, all regions added after the removed region will get a new index (index-1).
If the removed region affects the currently selected cell, a new
Spreadsheet.SelectionChangeEvent is fired.
index - Position of the target merged region in the POI merged region
array, 0-basedpublic void reloadAllMergedRegions()
This can be used if you want to add / remove multiple merged regions
directly from the POI model and need to update the component.
Note that you must also make sure that possible styles for the merged
regions are updated, if those were modified, by calling
reloadActiveSheetStyles().
public void reloadActiveSheetStyles()
public void setColumnHidden(int columnIndex,
boolean hidden)
Sheet.setColumnHidden(int, boolean).columnIndex - Index of the target column, 0-basedhidden - True to hide the target column, false to show it.public boolean isColumnHidden(int columnIndex)
Sheet.isColumnHidden(int).columnIndex - Index of the target column, 0-basedpublic void setRowHidden(int rowIndex,
boolean hidden)
Row.setZeroHeight(boolean).rowIndex - Index of the target row, 0-basedhidden - True to hide the target row, false to show it.public boolean isRowHidden(int rowIndex)
Row.getZeroHeight().rowIndex - Index of the target row, 0-basedpublic void read(File file) throws IOException
file - Data source file. Excel format is expected.IOException - If the file can't be read, or the file is of an invalid
format.public void read(InputStream inputStream) throws IOException
inputStream - Data source input stream. Excel format is expected.IOException - If handling the stream fails, or the data is in an invalid
format.public File write(String fileName) throws FileNotFoundException, IOException
fileName - The full name of the file. If the name doesn't end with '.xls'
or '.xlsx', the approriate one will be appended.Workbook, In the
file format of the original Workbook.FileNotFoundException - If file name was invalidIOException - If the file can't be written to for any reasonpublic void write(OutputStream outputStream) throws IOException
outputStream - The target streamIOException - If writing to the stream failspublic int getRowBufferSize()
Size is in pixels, the default is 200.
public void setRowBufferSize(int rowBufferInPixels)
The row buffer size determines the amount of content rendered outside the top and bottom edges of the visible cell area, for smoother scrolling.
rowBufferInPixels - The amount of extra content rendered outside the top and
bottom edges of the visible area.public int getColBufferSize()
Size is in pixels, the default is 200.
public void setColBufferSize(int colBufferInPixels)
The column buffer size determines the amount of content rendered outside the left and right edges of the visible cell area, for smoother scrolling.
colBufferInPixels - The amount of extra content rendered outside the left and
right edges of the visible area.public int getDefaultRowCount()
public void setDefaultRowCount(int defaultRowCount)
defaultRowCount - The number of rows to give sheets that are created with the
'+' button on the client side.public int getDefaultColumnCount()
public void setDefaultColumnCount(int defaultColumnCount)
defaultColumnCount - The number of columns to give sheets that are created with the
'+' button on the client side.public void reloadVisibleCellContents()
SpreadsheetComponentFactory, hyperlinks, cells'
comments and cells' contents. Also updates styles for the visible area.protected void setResource(String key, com.vaadin.server.Resource resource)
setResource in class com.vaadin.server.AbstractClientConnectorprotected ConditionalFormatter createConditionalFormatter()
ConditionalFormatter
implementation. This method is called each time we open a workbook.ConditionalFormatter that is tied to this spreadsheet.protected SpreadsheetStyleFactory createSpreadsheetStyleFactory()
SpreadsheetStyleFactory
implementation. This method is called each time we open a workbook.SpreadsheetStyleFactory that is tied to this
Spreadsheet.protected void reloadActiveSheetData()
protected void loadCustomEditorOnSelectedCell()
public int getVisibleSheetPOIIndex(int visibleSheetIndex)
visibleSheetIndex - Index of the sheet within this Spreadsheet, 0-basedpublic boolean isSheetProtected(int poiSheetIndex)
poiSheetIndex - Index of the target sheet within the POI model, 0-basedSheet is protected, false otherwise.public boolean isActiveSheetProtected()
Sheet is protected, false otherwise.public boolean isCellHidden(org.apache.poi.ss.usermodel.Cell cell)
cell - The cell to checkprotected boolean isCellEditable(org.apache.poi.ss.usermodel.Cell cell)
cell - The cell to checkpublic boolean isCellLocked(org.apache.poi.ss.usermodel.Cell cell)
cell - The cell to checkprotected SpreadsheetClientRpc getRpcProxy()
public void beforeClientResponse(boolean initial)
beforeClientResponse in interface com.vaadin.server.ClientConnectorbeforeClientResponse in class com.vaadin.ui.AbstractComponentpublic SpreadsheetStyleFactory getSpreadsheetStyleFactory()
public org.apache.poi.ss.usermodel.Workbook getWorkbook()
Workbook API
will not get automatically updated into the Spreadsheet component.
Use markCellAsDeleted(Cell, boolean),
markCellAsUpdated(Cell, boolean), or
reloadVisibleCellContents() to update content.
public void setWorkbook(org.apache.poi.ss.usermodel.Workbook workbook)
workbook - New workbook to loadpublic org.apache.poi.ss.usermodel.Sheet getActiveSheet()
Sheet API will
not get automatically updated into the Spreadsheet component.
Use markCellAsDeleted(Cell, boolean),
markCellAsUpdated(Cell, boolean), or
reloadVisibleCellContents() to update content.
protected void loadCells(int firstRow,
int firstColumn,
int lastRow,
int lastColumn)
firstRow - Index of the starting row, 1-basedfirstColumn - Index of the starting column, 1-basedlastRow - Index of the ending row, 1-basedlastColumn - Index of the ending column, 1-basedpublic void setRowHeight(int index,
float height)
index - Index of target row, 0-basedheight - New row height in pointspublic void setColumnWidth(int index,
int width)
index - Index of target column, 0-basedwidth - New column width in pixelspublic void setSpreadsheetComponentFactory(SpreadsheetComponentFactory customComponentFactory)
Workbook
has been set, all components will be reloaded.customComponentFactory - The new component factory to use.public SpreadsheetComponentFactory getSpreadsheetComponentFactory()
public void setPopup(String cellAddress, PopupButton popupButton)
Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.
cellAddress - address to the target cell, e.g. "C3"popupButton - PopupButton to set for the target cell. Passing null here
removes the pop-up button for the target cell.public void setPopup(int row,
int col,
PopupButton popupButton)
Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.
row - Row index of target cell, 0-basedcol - Column index of target cell, 0-basedpopupButton - PopupButton to set for the target cell. Passing null here
removes the pop-up button for the target cell.public void setPopup(org.apache.poi.ss.util.CellReference cellReference,
PopupButton popupButton)
Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.
cellReference - Reference to the target cellpopupButton - PopupButton to set for the target cell. Passing null here
removes the pop-up button for the target cell.public void registerTable(SpreadsheetTable table)
Populating the table content (pop-up button and other content) is the
responsibility of the table, with SpreadsheetTable.reload().
When the sheet is changed to a different sheet than the one that the
table belongs to, the table contents are cleared with
SpreadsheetTable.clear(). If the table is a filtering table, the
filters are NOT cleared (can be done with
SpreadsheetFilterTable.clearAllFilters().
The pop-up buttons are always removed by the spreadsheet when the sheet changes.
table - The table to registerpublic void unregisterTable(SpreadsheetTable table)
deleteTable(SpreadsheetTable) to completely remove the table.
table - The table to unregisterpublic void deleteTable(SpreadsheetTable table)
registerTable(SpreadsheetTable)), clears and removes all
possible filters (if table is a SpreadsheetFilterTable), and
clears all table pop-up buttons and content.table - The table to deletepublic HashSet<SpreadsheetTable> getTables()
registerTable(SpreadsheetTable).public List<SpreadsheetTable> getTablesForActiveSheet()
getActiveSheet()). See registerTable(SpreadsheetTable).public final String getCellValue(org.apache.poi.ss.usermodel.Cell cell)
DataFormatter with the current locale.
See
DataFormatter.formatCellValue(Cell, FormulaEvaluator, ConditionalFormattingEvaluator).cell - Cell to get the value frompublic boolean isGridlinesVisible()
public void setGridlinesVisible(boolean visible)
visible - True to show grid lines, false to hide thempublic boolean isRowColHeadingsVisible()
public void setRowColHeadingsVisible(boolean visible)
visible - true to show headings, false to hide thempublic com.vaadin.shared.Registration addSelectionChangeListener(Spreadsheet.SelectionChangeListener listener)
listener - Listener to add.public com.vaadin.shared.Registration addCellValueChangeListener(Spreadsheet.CellValueChangeListener listener)
listener - Listener to add.public com.vaadin.shared.Registration addFormulaValueChangeListener(Spreadsheet.FormulaValueChangeListener listener)
listener - Listener to add.@Deprecated public void removeSelectionChangeListener(Spreadsheet.SelectionChangeListener listener)
Registration.remove() method of
the Registration object returned from the
addSelectionChangeListener(SelectionChangeListener)
methodlistener - Listener to remove.@Deprecated public void removeCellValueChangeListener(Spreadsheet.CellValueChangeListener listener)
Registration.remove() method of
the Registration object returned from the
addCellValueChangeListener(CellValueChangeListener)
methodlistener - Listener to remove.public void addProtectedEditListener(Spreadsheet.ProtectedEditListener listener)
listener - The listener to add.@Deprecated public void removeProtectedEditListener(Spreadsheet.ProtectedEditListener listener)
Registration.remove() method of
the Registration object returned from the
addProtectedEditListener(ProtectedEditListener)
methodlistener - The listener to remove.public void createFreezePane(int rowSplit,
int colSplit)
rowSplit - Vertical position of the split, 1-based row indexcolSplit - Horizontal position of the split, 1-based column indexpublic void removeFreezePane()
public org.apache.poi.ss.util.CellReference getSelectedCellReference()
NOTE: other cells might also be selected: use
addSelectionChangeListener(SelectionChangeListener) to
get notified for all selection changes or call
getSelectedCellReferences().
public Set<org.apache.poi.ss.util.CellReference> getSelectedCellReferences()
public void addSheetChangeListener(Spreadsheet.SheetChangeListener listener)
listener - Listener to add@Deprecated public void removeSheetChangeListener(Spreadsheet.SheetChangeListener listener)
Registration.remove() method of
the Registration object returned from the
addSheetChangeListener(SheetChangeListener) methodlistener - Listener to removepublic Iterator<com.vaadin.ui.Component> iterator()
protected void onConnectorInit()
public void reload()
Functionally same as calling setWorkbook(Workbook) with
getWorkbook() parameter.
public void setStatusLabelValue(String value)
value - The new content. Can not be HTML.public String getStatusLabelValue()
public void setSelection(int row,
int col)
row - Row index, 0-basedcol - Column index, 0-basedpublic void setSelectionRange(int row1,
int col1,
int row2,
int col2)
row1 - Index of the first row of the area, 0-basedcol1 - Index of the first column of the area, 0-basedrow2 - Index of the last row of the area, 0-basedcol2 - Index of the last column of the area, 0-basedpublic void setSelection(String selectionRange)
selectionRange - The wanted range, e.g. "A3" or "B3:C5"public ConditionalFormatter getConditionalFormatter()
ConditionalFormatter used by this Spreadsheetpublic void reset()
Workbook, if any, and loads a new empty XSLX
Workbook.
Note: Discards all data. Be sure to write out the old Workbook if needed.public void readDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext)
readDesign in interface com.vaadin.ui.ComponentreadDesign in class com.vaadin.ui.AbstractComponentprotected Collection<String> getCustomAttributes()
getCustomAttributes in class com.vaadin.ui.AbstractComponentpublic void writeDesign(org.jsoup.nodes.Element design,
com.vaadin.ui.declarative.DesignContext designContext)
writeDesign in interface com.vaadin.ui.ComponentwriteDesign in class com.vaadin.ui.AbstractComponentpublic String getDefaultPercentageFormat()
Default is "0.00%".
public void setDefaultPercentageFormat(String defaultPercentageFormat)
Default is "0.00%".
public void setCommentAuthorProvider(Spreadsheet.CommentAuthorProvider commentAuthorProvider)
commentAuthorProvider - New providerpublic Spreadsheet.CommentAuthorProvider getCommentAuthorProvider()
public void editCellComment(org.apache.poi.ss.util.CellReference cr)
cr - Reference to the cell containing the comment to editpublic void setFunctionBarVisible(boolean functionBarVisible)
functionBarVisible - True to show the top bar, false to hide it.public boolean isFunctionBarVisible()
public void setSheetSelectionBarVisible(boolean sheetSelectionBarVisible)
sheetSelectionBarVisible - True to show the sheet selection bar, false to hide it.public boolean isSheetSelectionBarVisible()
public void setReportStyle(boolean reportStyle)
reportStyle - True to hide both toolbars, false to show them.public boolean isReportStyle()
public void setInvalidFormulaErrorMessage(String invalidFormulaErrorMessage)
public int getTabIndex()
getTabIndex in interface com.vaadin.ui.Component.Focusablepublic void setTabIndex(int tabIndex)
setTabIndex in interface com.vaadin.ui.Component.Focusablepublic void focus()
focus in interface com.vaadin.ui.Component.Focusablefocus in class com.vaadin.ui.AbstractComponentprotected void setGroupingCollapsed(boolean isCols,
int index,
boolean collapsed)
isCols - true when collapsing columns, false
when collapsing rowsindex - A column that is part of the group, 0-basedcollapsed - If the group should be collapsed or notprotected void levelHeaderClicked(boolean isCols,
int level)
isCols - true if the user clicked on cols, false for row level headerslevel - which level the user clickedpublic void addSheetOverlay(SheetOverlayWrapper image)
public int getMinimumRowHeightForComponents()
public void setMinimumRowHeightForComponents(int minimumRowHeightForComponents)
minimumRowHeightForComponents - the minimum row height in pointsCopyright © 2013–2026 Vaadin Ltd. All rights reserved.