You're viewing an older version of Vaadin JavaDoc. Please see version 24.6.4 for the latest.
com.vaadin.flow.component.spreadsheet.

Class Spreadsheet

    • Field Detail

      • tabIndex

        public int tabIndex
      • HIDE_FUNCTION_BAR_STYLE

        public static final String HIDE_FUNCTION_BAR_STYLE

        This is a style which hides the top (address and formula) bar.

        See Also:

        Constant Field Values

      • HIDE_TABSHEET_STYLE

        public static final String HIDE_TABSHEET_STYLE

        This is a style which hides the bottom (sheet selection) bar.

        See Also:

        Constant Field Values

      • mergedRegionCounter

        protected int mergedRegionCounter
      • initialSheetSelection

        protected String initialSheetSelection
    • Constructor Detail

      • Spreadsheet

        public Spreadsheet​(int defaultRowCount,
                           int defaultColumnCount)

        Creates a new Spreadsheet component using the newer Excel version format 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.

        Parameters:

        defaultRowCount - Default row count for new sheets

        defaultColumnCount - Default column count for new sheets

      • Spreadsheet

        public Spreadsheet​(org.apache.poi.ss.usermodel.Workbook workbook)

        Creates a new Spreadsheet component and loads the given Workbook.

        Parameters:

        workbook - Workbook to load

      • Spreadsheet

        public Spreadsheet​(File file)
                    throws IOException

        Creates a new Spreadsheet component and loads the given Excel file.

        Parameters:

        file - Excel file

        Throws:

        IOException - If file has invalid format or there is no access to the file

      • Spreadsheet

        public Spreadsheet​(InputStream inputStream)
                    throws IOException

        Creates a new Spreadsheet component based on the given input stream. The expected format is that of an Excel file.

        Parameters:

        inputStream - Stream that provides Excel-formatted data.

        Throws:

        IOException - If there is an error handling the stream, or if the data is in an invalid format.

    • Method Detail

      • setId

        public void setId​(String id)

        Description copied from class: Component

        Sets the id of the root element of this component. The id is used with various APIs to identify the element, and it should be unique on the page.

        Overrides:

        setId in class Component

        Parameters:

        id - the id to set, or "" to remove any previously set id

      • setHeight

        public void setHeight​(String height)

        Description copied from interface: HasSize

        Sets the height of the component.

        The height should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided height value is null then height is removed.

        Specified by:

        setHeight in interface HasSize

        Parameters:

        height - the height to set, may be null

      • setWidth

        public void setWidth​(String width)

        Description copied from interface: HasSize

        Sets the width of the component.

        The width should be in a format understood by the browser, e.g. "100px" or "2.5em".

        If the provided width value is null then width is removed.

        Specified by:

        setWidth in interface HasSize

        Parameters:

        width - the width to set, may be null

      • getDescription

        public String getDescription()
      • getDescriptionContentMode

        public ContentMode getDescriptionContentMode()
      • getCaption

        public String getCaption()
      • getPrimaryStyleName

        public String getPrimaryStyleName()
      • getErrorMessage

        public String getErrorMessage()
      • getErrorLevel

        public ErrorLevel getErrorLevel()
      • isCaptionAsHtml

        public boolean isCaptionAsHtml()
      • isEnabled

        public boolean isEnabled()

        Description copied from interface: HasEnabled

        Returns whether the object is enabled or disabled.

        Object may be enabled by itself by but if its ascendant is disabled then it's considered as (implicitly) disabled.

        Specified by:

        isEnabled in interface HasEnabled

        Returns:

        enabled state of the object

      • getRegisteredEventListeners

        public Set<String> getRegisteredEventListeners()
      • getColumnBufferSize

        public int getColumnBufferSize()
      • getCols

        public int getCols()
      • getColGroupingMax

        public int getColGroupingMax()
      • getRowGroupingMax

        public int getRowGroupingMax()
      • isColGroupingInversed

        public boolean isColGroupingInversed()
      • isRowGroupingInversed

        public boolean isRowGroupingInversed()
      • getDefRowH

        public float getDefRowH()
      • getDefColW

        public int getDefColW()
      • getRowH

        public float[] getRowH()
      • getColW

        public int[] getColW()
      • isReload

        public boolean isReload()
      • getSheetIndex

        public int getSheetIndex()
      • getSheetNames

        public String[] getSheetNames()
      • getLockedColumnIndexes

        public Set<Integer> getLockedColumnIndexes()
      • getLockedRowIndexes

        public Set<Integer> getLockedRowIndexes()
      • getShiftedCellBorderStyles

        public ArrayList<String> getShiftedCellBorderStyles()
      • getConditionalFormattingStyles

        public HashMap<Integer,​String> getConditionalFormattingStyles()
      • getVerticalScrollPositions

        public int[] getVerticalScrollPositions()
      • getHorizontalScrollPositions

        public int[] getHorizontalScrollPositions()
      • isSheetProtected

        public boolean isSheetProtected()
      • isWorkbookProtected

        public boolean isWorkbookProtected()
      • getVisibleCellComments

        public ArrayList<String> getVisibleCellComments()
      • getInvalidFormulaCells

        public Set<String> getInvalidFormulaCells()
      • isHasActions

        public boolean isHasActions()
      • isDisplayGridlines

        public boolean isDisplayGridlines()
      • isDisplayRowColHeadings

        public boolean isDisplayRowColHeadings()
      • getVerticalSplitPosition

        public int getVerticalSplitPosition()
      • getHorizontalSplitPosition

        public int getHorizontalSplitPosition()
      • getInfoLabelValue

        public String getInfoLabelValue()
      • isWorkbookChangeToggle

        public boolean isWorkbookChangeToggle()
      • getInvalidFormulaErrorMessage

        public String getInvalidFormulaErrorMessage()
      • isLockFormatColumns

        public boolean isLockFormatColumns()
      • isLockFormatRows

        public boolean isLockFormatRows()
      • getNamedRanges

        public List<String> getNamedRanges()
      • _setRowBufferSize

        public void _setRowBufferSize​(int rowBufferSize)
      • setColumnBufferSize

        public void setColumnBufferSize​(int columnBufferSize)
      • setRows

        public void setRows​(int rows)
      • setCols

        public void setCols​(int cols)
      • setColGroupingData

        public void setColGroupingData​(List<GroupingData> colGroupingData)
      • setRowGroupingData

        public void setRowGroupingData​(List<GroupingData> rowGroupingData)
      • setColGroupingMax

        public void setColGroupingMax​(int colGroupingMax)
      • setRowGroupingMax

        public void setRowGroupingMax​(int rowGroupingMax)
      • setColGroupingInversed

        public void setColGroupingInversed​(boolean colGroupingInversed)
      • setRowGroupingInversed

        public void setRowGroupingInversed​(boolean rowGroupingInversed)
      • setDefRowH

        public void setDefRowH​(float defRowH)
      • setDefColW

        public void setDefColW​(int defColW)
      • setRowH

        public void setRowH​(float[] rowH)
      • setColW

        public void setColW​(int[] colW)
      • setReload

        public void setReload​(boolean reload)
      • setSheetIndex

        public void setSheetIndex​(int sheetIndex)
      • setSheetNames

        public void setSheetNames​(String[] sheetNames)
      • setCellStyleToCSSStyle

        public void setCellStyleToCSSStyle​(HashMap<Integer,​String> cellStyleToCSSStyle)
      • setRowIndexToStyleIndex

        public void setRowIndexToStyleIndex​(HashMap<Integer,​Integer> rowIndexToStyleIndex)
      • setColumnIndexToStyleIndex

        public void setColumnIndexToStyleIndex​(HashMap<Integer,​Integer> columnIndexToStyleIndex)
      • setLockedColumnIndexes

        public void setLockedColumnIndexes​(Set<Integer> lockedColumnIndexes)
      • setLockedRowIndexes

        public void setLockedRowIndexes​(Set<Integer> lockedRowIndexes)
      • setShiftedCellBorderStyles

        public void setShiftedCellBorderStyles​(ArrayList<String> shiftedCellBorderStyles)
      • setConditionalFormattingStyles

        public void setConditionalFormattingStyles​(HashMap<Integer,​String> conditionalFormattingStyles)
      • setHiddenColumnIndexes

        public void setHiddenColumnIndexes​(ArrayList<Integer> hiddenColumnIndexes)
      • setHiddenRowIndexes

        public void setHiddenRowIndexes​(ArrayList<Integer> hiddenRowIndexes)
      • setVerticalScrollPositions

        public void setVerticalScrollPositions​(int[] verticalScrollPositions)
      • setHorizontalScrollPositions

        public void setHorizontalScrollPositions​(int[] horizontalScrollPositions)
      • setSheetProtected

        public void setSheetProtected​(boolean sheetProtected)
      • setWorkbookProtected

        public void setWorkbookProtected​(boolean workbookProtected)
      • setCellKeysToEditorIdMap

        public void setCellKeysToEditorIdMap​(HashMap<String,​String> cellKeysToEditorIdMap)
      • setComponentIDtoCellKeysMap

        public void setComponentIDtoCellKeysMap​(HashMap<String,​String> componentIDtoCellKeysMap)
      • setHyperlinksTooltips

        public void setHyperlinksTooltips​(HashMap<String,​String> hyperlinksTooltips)
      • setCellCommentAuthors

        public void setCellCommentAuthors​(HashMap<String,​String> cellCommentAuthors)
      • setVisibleCellComments

        public void setVisibleCellComments​(ArrayList<String> visibleCellComments)
      • setInvalidFormulaCells

        public void setInvalidFormulaCells​(Set<String> invalidFormulaCells)
      • setHasActions

        public void setHasActions​(boolean hasActions)
      • setDisplayGridlines

        public void setDisplayGridlines​(boolean displayGridlines)
      • setDisplayRowColHeadings

        public void setDisplayRowColHeadings​(boolean displayRowColHeadings)
      • setVerticalSplitPosition

        public void setVerticalSplitPosition​(int verticalSplitPosition)
      • setHorizontalSplitPosition

        public void setHorizontalSplitPosition​(int horizontalSplitPosition)
      • setInfoLabelValue

        public void setInfoLabelValue​(String infoLabelValue)
      • setWorkbookChangeToggle

        public void setWorkbookChangeToggle​(boolean workbookChangeToggle)
      • setLockFormatColumns

        public void setLockFormatColumns​(boolean lockFormatColumns)
      • setLockFormatRows

        public void setLockFormatRows​(boolean lockFormatRows)
      • setNamedRanges

        public void setNamedRanges​(List<String> namedRanges)
      • createCellValueManager

        protected CellValueManager createCellValueManager()

        Override if there are desired changes or temporary bug fixes, but be careful - this class should cache values for performance.

        Returns:

        CellValueManager

      • customInit

        protected void customInit()

        Implement this to perform custom initialization in subclasses. Called before loading any workbook, at the end of the required init() actions.

      • removeActionHandler

        public void removeActionHandler​(Action.Handler actionHandler)

        Description copied from interface: Action.Container

        Removes a previously registered action handler for the contents of this container.

        Specified by:

        removeActionHandler in interface Action.Container

        Parameters:

        actionHandler - the handler to be removed.

      • setCellValueHandler

        public void setCellValueHandler​(Spreadsheet.CellValueHandler customCellValueHandler)

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

        Parameters:

        customCellValueHandler - New handler or null if none should be used

      • setCellDeletionHandler

        public void setCellDeletionHandler​(Spreadsheet.CellDeletionHandler customCellDeletionHandler)

        Sets the Spreadsheet.CellDeletionHandler for this component (not workbook/sheet specific). It is called when a cell has been deleted by the user.

        Parameters:

        customCellDeletionHandler - New handler or null if none should be used

      • getContextMenuManager

        public ContextMenuManager getContextMenuManager()

        Gets the ContextMenuManager for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The ContextMenuManager

      • getCellSelectionManager

        public CellSelectionManager getCellSelectionManager()

        Gets the CellSelectionManager for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The CellSelectionManager

      • getCellValueManager

        public CellValueManager getCellValueManager()

        Gets the CellValueManager for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The CellValueManager

      • getCellShifter

        protected CellSelectionShifter getCellShifter()

        Gets the CellShifter for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The CellShifter

      • getSpreadsheetHistoryManager

        public SpreadsheetHistoryManager getSpreadsheetHistoryManager()

        Gets the SpreadsheetHistoryManager for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The SpreadsheetHistoryManager

      • getMergedRegionContainer

        protected MergedRegionUtil.MergedRegionContainer getMergedRegionContainer()

        Gets the MergedRegionContainer for this Spreadsheet. This is component (not workbook/sheet) specific.

        Returns:

        The MergedRegionContainer

      • getFirstColumn

        public int getFirstColumn()

        Returns the first visible column in the main scroll area (NOT freeze pane)

        Returns:

        Index of first visible column, 1-based

      • getLastColumn

        public int getLastColumn()

        Returns the last visible column in the main scroll area (NOT freeze pane)

        Returns:

        Index of last visible column, 1-based

      • getFirstRow

        public int getFirstRow()

        Returns the first visible row in the scroll area (not freeze pane)

        Returns:

        Index of first visible row, 1-based

      • getLastRow

        public int getLastRow()

        Returns the last visible row in the main scroll area (NOT freeze pane)

        Returns:

        Index of last visible row, 1-based

      • getLastFrozenRow

        public int getLastFrozenRow()

        Returns the index the last frozen row (last row in top freeze pane).

        Returns:

        Last frozen row or 0 if none

      • getLastFrozenColumn

        public int getLastFrozenColumn()

        Returns the index the last frozen column (last column in left freeze pane).

        Returns:

        Last frozen column or 0 if none

      • isChartsEnabled

        public boolean isChartsEnabled()

        Returns true if embedded charts are displayed

        Returns:

        See Also:

        setChartsEnabled(boolean)

      • setChartsEnabled

        public void setChartsEnabled​(boolean chartsEnabled)

        Use this method to define whether embedded charts should be displayed in the spreadsheet or not.

        Parameters:

        chartsEnabled -

      • isRerenderPending

        public boolean isRerenderPending()

        Returns true if the component is being fully re-rendered after this round-trip (sheet change etc.)

        Returns:

        true if re-render will happen, false otherwise

      • onSheetScroll

        protected void onSheetScroll​(int firstRow,
                                     int firstColumn,
                                     int lastRow,
                                     int lastColumn)

        This method is called when the sheet is scrolled. It takes care of sending newly revealed data to the client side.

        Parameters:

        firstRow - Index of first visible row after the scroll, 1-based

        firstColumn - Index of first visible column after the scroll, 1-based

        lastRow - Index of last visible row after the scroll, 1-based

        lastColumn - Index of first visible column after the scroll, 1-based

      • isRangeEditable

        protected boolean isRangeEditable​(org.apache.poi.ss.util.CellRangeAddress cellRangeAddress)

        Tells whether the given cell range is editable or not.

        Parameters:

        cellRangeAddress - Cell range to test

        Returns:

        True if range is editable, false otherwise.

      • isRangeEditable

        protected boolean isRangeEditable​(int row1,
                                          int col1,
                                          int row2,
                                          int col2)

        Determines if the given cell range is editable or not.

        Parameters:

        row1 - Index of starting row, 0-based

        col1 - Index of starting column, 0-based

        row2 - Index of ending row, 0-based

        col2 - Index of ending column, 0-based

        Returns:

        True if the whole range is editable, false otherwise.

      • createCorrectCellRangeAddress

        protected org.apache.poi.ss.util.CellRangeAddress createCorrectCellRangeAddress​(String addressString)

        Creates a CellRangeAddress from the given cell address string. Also checks that the range is valid within the currently active sheet. If it is not, the resulting range will be truncated to fit the active sheet.

        Parameters:

        addressString - Cell address string, e.g. "B3:C5"

        Returns:

        A CellRangeAddress based on the given coordinates.

      • createCorrectCellRangeAddress

        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. Also checks that the range is valid within the currently active sheet. If it is not, the resulting range will be truncated to fit the active sheet.

        Parameters:

        row1 - Index of the starting row, 1-based

        col1 - Index of the starting column, 1-based

        row2 - Index of the ending row, 1-based

        col2 - Index of the ending column, 1-based

        Returns:

        A CellRangeAddress based on the given coordinates.

      • setLocale

        public void setLocale​(Locale locale)
      • onAttach

        protected void onAttach​(AttachEvent attachEvent)

        Description copied from class: Component

        Called when the component is attached to a UI.

        The default implementation does nothing.

        This method is invoked before the AttachEvent is fired for the component.

        Overrides:

        onAttach in class Component

        Parameters:

        attachEvent - the attach event

      • setSheetHidden

        public void setSheetHidden​(int sheetPOIIndex,
                                   org.apache.poi.ss.usermodel.SheetVisibility visibility)
                            throws IllegalArgumentException

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

        Parameters:

        sheetPOIIndex - Index of the target sheet within the POI model, 0-based

        visibility - Visibility state to set: visible, hidden, very hidden.

        Throws:

        IllegalArgumentException - If the index or state is invalid, or if trying to hide the only visible sheet.

      • setSheetHidden

        @Deprecated
        public void setSheetHidden​(int sheetPOIIndex,
                                   int hidden)
                            throws IllegalArgumentException

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

        Parameters:

        hidden - Visibility state to set: 0-visible, 1-hidden, 2-very hidden.

        sheetPOIIndex - Index of the target sheet within the POI model, 0-based

        Throws:

        IllegalArgumentException - If the index or state is invalid, or if trying to hide the only visible sheet.

      • getVisibleSheetNames

        public String[] getVisibleSheetNames()

        Returns an array containing the names of the currently visible sheets. Does not contain the names of hidden or very hidden sheets.

        To get all of the current Workbook's sheet names, you should access the POI API with getWorkbook().

        Returns:

        Names of the currently visible sheets.

      • setSheetName

        public void setSheetName​(int sheetIndex,
                                 String sheetName)
                          throws IllegalArgumentException

        Sets a name for the sheet at the given visible sheet index.

        Parameters:

        sheetIndex - Index of the target sheet among the visible sheets, 0-based

        sheetName - New sheet name. Not null, empty nor longer than 31 characters. Must be unique within the Workbook.

        Throws:

        IllegalArgumentException - If the index is invalid, or if the sheet name is invalid. See WorkbookUtil.validateSheetName(String).

      • setSheetNameWithPOIIndex

        public void setSheetNameWithPOIIndex​(int sheetIndex,
                                             String sheetName)
                                      throws IllegalArgumentException

        Sets a name for the sheet at the given POI model index.

        Parameters:

        sheetIndex - Index of the target sheet within the POI model, 0-based

        sheetName - New sheet name. Not null, empty nor longer than 31 characters. Must be unique within the Workbook.

        Throws:

        IllegalArgumentException - If the index is invalid, or if the sheet name is invalid. See WorkbookUtil.validateSheetName(String).

      • setSheetProtected

        public void setSheetProtected​(int sheetPOIIndex,
                                      String password)

        Sets the protection enabled with the given password for the sheet at the given index. null password removes the protection.

        Parameters:

        sheetPOIIndex - Index of the target sheet within the POI model, 0-based

        password - The password to set for the protection. Pass null to remove the protection.

      • setActiveSheetProtected

        public void setActiveSheetProtected​(String password)

        Sets the protection enabled with the given password for the currently active sheet. null password removes the protection.

        Parameters:

        password - The password to set for the protection. Pass null to remove the protection.

      • createNewSheet

        public void createNewSheet​(String sheetName,
                                   int rows,
                                   int columns)
                            throws IllegalArgumentException

        Creates a new sheet as the last sheet and sets it as the active sheet. If the sheetName given is null, then the sheet name is automatically generated by Apache POI in Workbook.createSheet().

        Parameters:

        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 have

        columns - Number of columns the sheet should have

        Throws:

        IllegalArgumentException - If the sheet name is empty or over 31 characters long or not unique.

      • deleteSheetWithPOIIndex

        public void deleteSheetWithPOIIndex​(int poiSheetIndex)
                                     throws IllegalArgumentException

        Deletes the sheet with the given POI model index. Note: A workbook must contain at least one visible sheet.

        Parameters:

        poiSheetIndex - POI model index of the sheet to delete, 0-based, max value Workbook.getNumberOfSheets() -1.

        Throws:

        IllegalArgumentException - In case there is only one visible sheet, or if the index is invalid.

      • deleteSheet

        public void deleteSheet​(int sheetIndex)
                         throws IllegalArgumentException

        Deletes the sheet at the given index. Note: A workbook must contain at least one visible sheet.

        Parameters:

        sheetIndex - Index of the sheet to delete among the visible sheets, 0-based, maximum value getNumberOfVisibleSheets() -1.

        Throws:

        IllegalArgumentException - In case there is only one visible sheet, or if the given index is invalid.

      • getNumberOfVisibleSheets

        public int getNumberOfVisibleSheets()

        Returns the number of currently visible sheets in the component. Doesn't include the hidden or very hidden sheets in the POI model.

        Returns:

        Number of visible sheets.

      • getNumberOfSheets

        public int getNumberOfSheets()

        Returns the total number of sheets in the workbook (includes hidden and very hidden sheets).

        Returns:

        Total number of sheets in the workbook

      • getActiveSheetIndex

        public int getActiveSheetIndex()

        Returns the index of the currently active sheet among the visible sheets ( hidden or very hidden sheets not included).

        Returns:

        Index of the active sheet, 0-based

      • getActiveSheetPOIIndex

        public int getActiveSheetPOIIndex()

        Returns the POI model index of the currently active sheet (index among all sheets including hidden and very hidden sheets).

        Returns:

        POI model index of the active sheet, 0-based

      • setActiveSheetIndex

        public void setActiveSheetIndex​(int sheetIndex)
                                 throws IllegalArgumentException

        Sets the currently active sheet within the sheets that are visible.

        Parameters:

        sheetIndex - Index of the target sheet (among the visible sheets), 0-based

        Throws:

        IllegalArgumentException - If the index is invalid

      • setActiveSheetWithPOIIndex

        public void setActiveSheetWithPOIIndex​(int sheetIndex)
                                        throws IllegalArgumentException

        Sets the currently active sheet. The sheet at the given index should be visible (not hidden or very hidden).

        Parameters:

        sheetIndex - Index of sheet in the POI model (contains all sheets), 0-based

        Throws:

        IllegalArgumentException - If the index is invalid, or if the sheet at the given index is hidden or very hidden.

      • onSheetSelected

        protected void onSheetSelected​(int tabIndex,
                                       int scrollLeft,
                                       int scrollTop)

        This method will be called when a selected sheet change is requested.

        Parameters:

        tabIndex - Index of the sheet to select.

        scrollLeft - Current horizontal scroll position

        scrollTop - Current vertical scroll position

      • onNewSheetCreated

        protected void onNewSheetCreated​(int scrollLeft,
                                         int scrollTop)

        This method is called when the creation of a new sheet has been requested.

        Parameters:

        scrollLeft - Current horizontal scroll position

        scrollTop - Current vertical scroll position

      • onSheetRename

        protected void onSheetRename​(int sheetIndex,
                                     String sheetName)

        This method is called when a request to rename a sheet has been made.

        Parameters:

        sheetIndex - Index of the sheet to rename (among visible sheets).

        sheetName - New name for the sheet.

      • getColumns

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

        Returns:

        Number of visible columns.

      • getRows

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

        Returns:

        Number of visible rows.

      • getDataFormatter

        public org.apache.poi.ss.usermodel.DataFormatter getDataFormatter()

        Gets the current DataFormatter.

        Returns:

        The data formatter for this Spreadsheet.

      • getCell

        public org.apache.poi.ss.usermodel.Cell getCell​(String cellAddress)

        Returns the Cell at the given address. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        cellAddress - Address of the Cell to return, e.g. "A3"

        Returns:

        The cell at the given address, or null if not defined

      • getCell

        public org.apache.poi.ss.usermodel.Cell getCell​(int row,
                                                        int col)

        Returns the Cell at the given coordinates. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        row - Row index of the cell to return, 0-based

        col - Column index of the cell to return, 0-based

        Returns:

        The cell at the given coordinates, or null if not defined

      • getCell

        public 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. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        row - Row index of the cell to return, 0-based

        col - Column index of the cell to return, 0-based

        sheet - Sheet of the cell

        Returns:

        The cell at the given coordinates, or null if not defined

      • getCell

        public org.apache.poi.ss.usermodel.Cell getCell​(org.apache.poi.ss.util.CellReference cellReference)

        Returns the Cell corresponding to the given reference. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        cellReference - Reference to the cell to return

        Returns:

        The cell corresponding to the given reference, or null if not defined

      • getCell

        public org.apache.poi.ss.usermodel.Cell getCell​(String sheetName,
                                                        int row,
                                                        int column)

        Returns the Cell at the given coordinates. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        sheetName - Name of the sheet the cell is on, or current sheet if null

        row - Row index of the cell to return, 0-based

        column - Column index of the cell to return, 0-based

        Returns:

        The cell at the given coordinates, or null if not defined

      • getCell

        public 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. If the cell is updated in outside code, call refreshCells(Cell...) AFTER ALL UPDATES (value, type, formatting or style) to mark the cell as "dirty".

        Parameters:

        cellReference - Reference to the cell to return

        sheet - Sheet of the cell

        Returns:

        The cell corresponding to the given reference, or null if not defined

      • deleteCell

        public void deleteCell​(int row,
                               int col)

        Deletes the cell from the sheet and the underlying POI model as well. This really deletes the cell, instead of just making it's value blank.

        Parameters:

        row - Row index of the cell to delete, 0-based

        col - Column index of the cell to delete, 0-based

      • refreshCells

        public void refreshCells​(org.apache.poi.ss.usermodel.Cell... cells)

        Refreshes the given cell(s). Should be called when the cell value/formatting/style/etc. updating is done. NOTE: For optimal performance temporarily collect your updated cells and call this method only once per update cycle. Calling this method repeatedly for individual cells is not a good idea.

        Parameters:

        cells - Cell(s) to update

      • refreshCells

        public void refreshCells​(Collection<org.apache.poi.ss.usermodel.Cell> cells)

        Refreshes the given cell(s). Should be called when the cell value/formatting/style/etc. updating is done. NOTE: For optimal performance temporarily collect your updated cells and call this method only once per update cycle. Calling this method repeatedly for individual cells is not a good idea.

        Parameters:

        cells - A Collection of Cells to update

      • markCellAsDeleted

        public void markCellAsDeleted​(org.apache.poi.ss.usermodel.Cell cell,
                                      boolean cellStyleUpdated)

        Marks the cell as deleted. This method should be called after removing a cell from the Workbook using POI API.

        Parameters:

        cellStyleUpdated - True if the cell style has changed

        cell - The cell that has been deleted.

      • createFormulaCell

        public org.apache.poi.ss.usermodel.Cell createFormulaCell​(int row,
                                                                  int col,
                                                                  String formula)
                                                           throws IllegalArgumentException

        Creates a new Formula type cell with the given formula. After all editing is done, call refreshCells(Cell...) or refreshAllCellValues() to make sure client side is updated.

        Parameters:

        row - Row index of the new cell, 0-based

        col - Column index of the new cell, 0-based

        formula - The formula to set to the new cell (should NOT start with "=" nor "+")

        Returns:

        The newly created cell

        Throws:

        IllegalArgumentException - If columnIndex < 0 or greater than the maximum number of supported columns (255 for *.xls, 1048576 for *.xlsx)

      • createCell

        public org.apache.poi.ss.usermodel.Cell createCell​(int row,
                                                           int col,
                                                           Object value)
                                                    throws IllegalArgumentException

        Create a new cell (or replace existing) with the given value, the type of the value parameter will define the type of the cell. The value may be of the following types: Boolean, Calendar, Date, Double or String. The default type will be String, value of (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.

        Parameters:

        row - Row index of the new cell, 0-based

        col - Column index of the new cell, 0-based

        value - Object representing the type and value of the Cell

        Returns:

        The newly created cell

        Throws:

        IllegalArgumentException - If columnIndex < 0 or greater than the maximum number of supported columns (255 for *.xls, 1048576 for *.xlsx)

      • refreshAllCellValues

        public void refreshAllCellValues()

        Forces recalculation and update to the client side for values of all of the sheet's cells. Note: DOES NOT UPDATE STYLES; use refreshCells(Cell...) when cell styles change.

      • setMaxColumns

        public void setMaxColumns​(int cols)

        Set the number of columns shown for the current sheet. Any null cells are left empty. Any cells outside the given columns are hidden. Does not update the actual POI-based model! The default value will be the actual size of the sheet from the POI model.

        Parameters:

        cols - New maximum column count.

      • setMaxRows

        public void setMaxRows​(int rows)

        Set the number of rows shown for the current sheet. Any null cells are left empty. Any cells outside the given rows are hidden. Does not update the actual POI-based model! The default value will be the actual size of the sheet from the POI model.

        Parameters:

        rows - New maximum row count.

      • setSheetMaxSize

        public void setSheetMaxSize​(int rows,
                                    int cols)

        Does setMaxColumns(int) and setMaxRows(int) in one method.

        Parameters:

        rows - Maximum row count

        cols - Maximum column count

      • getDefaultColumnWidth

        public int getDefaultColumnWidth()

        Gets the default column width for the currently active sheet. This is derived from the active sheet's (getActiveSheet()) default column width (Sheet getDefaultColumnWidth()).

        Returns:

        The default column width in PX

      • setDefaultColumnWidth

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

        Parameters:

        widthPX - The default column width in pixels

      • getDefaultRowHeight

        public float getDefaultRowHeight()

        Gets the default row height in points. By default it should be the same as Sheet.getDefaultRowHeightInPoints() for the currently active sheet getActiveSheet().

        Returns:

        Default row height for the currently active sheet, in points.

      • setDefaultRowHeight

        public void setDefaultRowHeight​(float heightPT)

        Sets the default row height in points for this Spreadsheet and the currently active sheet, returned by getActiveSheet().

        Parameters:

        heightPT - New default row height in points.

      • onRowHeaderDoubleClick

        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.

        Parameters:

        rowIndex - Index of the target rowIndex, 0-based

      • onColumnAutofit

        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.

        Parameters:

        columnIndex - Index of the target column, 0-based

      • autofitColumn

        public void autofitColumn​(int columnIndex)

        Sets the column to automatically adjust the column width to fit the largest cell content within the column. This is a POI feature, and is meant to be called after all the data for the target column has been written. See Sheet.autoSizeColumn(int).

        This does not take into account cells that have custom Vaadin components inside them.

        Parameters:

        columnIndex - Index of the target column, 0-based

      • 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 for n, the rows will be shifted upwards. This method ensures that rows can't wrap around.

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

        Parameters:

        startRow - The first row to shift, 0-based

        endRow - The last row to shift, 0-based

        n - Number of rows to shift, positive numbers shift down, negative numbers shift up.

      • 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 for n, the rows will be shifted upwards. This method ensures that rows can't wrap around.

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

        Parameters:

        startRow - The first row to shift, 0-based

        endRow - The last row to shift, 0-based

        n - Number of rows to shift, positive numbers shift down, negative numbers shift up.

        copyRowHeight - True to copy the row height during the shift

        resetOriginalRowHeight - True to set the original row's height to the default

      • getFormulaEvaluator

        public org.apache.poi.ss.usermodel.FormulaEvaluator getFormulaEvaluator()

        Returns:

        the common FormulaEvaluator instance.

      • getConditionalFormattingEvaluator

        public org.apache.poi.ss.formula.ConditionalFormattingEvaluator getConditionalFormattingEvaluator()

        POI, as of 4.0.0, now accepts this as an argument to formula evaluation. Some conditional formats can modify the display text of a cell.

        Returns:

        the common ConditionalFormattingEvaluator instance.

      • deleteRows

        public void deleteRows​(int startRow,
                               int endRow)

        Deletes rows. See 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.

        Parameters:

        startRow - Index of the starting row, 0-based

        endRow - Index of the ending row, 0-based

      • addMergedRegion

        public void addMergedRegion​(String selectionRange)

        Merges cells. See Sheet.addMergedRegion(CellRangeAddress).

        Parameters:

        selectionRange - The cell range to merge, e.g. "B3:C5"

      • addMergedRegion

        public void addMergedRegion​(int row1,
                                    int col1,
                                    int row2,
                                    int col2)

        Merge cells. See Sheet.addMergedRegion(CellRangeAddress).

        Parameters:

        row1 - Index of the starting row of the merged region, 0-based

        col1 - Index of the starting column of the merged region, 0-based

        row2 - Index of the ending row of the merged region, 0-based

        col2 - Index of the ending column of the merged region, 0-based

      • addMergedRegion

        public void addMergedRegion​(org.apache.poi.ss.util.CellRangeAddress region)
                             throws IllegalArgumentException

        Merges the given cells. See 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.

        Parameters:

        region - The range of cells to merge

        Throws:

        IllegalArgumentException - If the given region overlaps with or encloses another existing region within the sheet.

      • removeMergedRegion

        public void removeMergedRegion​(int index)

        Removes a merged region with the given index. Current merged regions can be inspected within the currently active sheet with 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.

        Parameters:

        index - Position of the target merged region in the POI merged region array, 0-based

      • reloadAllMergedRegions

        public void reloadAllMergedRegions()

        Discards all current merged regions for the sheet and reloads them from the POI model.

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

      • reloadActiveSheetStyles

        public void reloadActiveSheetStyles()

        Reloads all the styles for the currently active sheet.

      • setColumnHidden

        public void setColumnHidden​(int columnIndex,
                                    boolean hidden)

        Hides or shows the given column, see Sheet.setColumnHidden(int, boolean).

        Parameters:

        columnIndex - Index of the target column, 0-based

        hidden - True to hide the target column, false to show it.

      • isColumnHidden

        public boolean isColumnHidden​(int columnIndex)

        Gets the visibility state of the given column. See Sheet.isColumnHidden(int).

        Parameters:

        columnIndex - Index of the target column, 0-based

        Returns:

        true if the target column is hidden, false if it is visible.

      • setRowHidden

        public void setRowHidden​(int rowIndex,
                                 boolean hidden)

        Hides or shows the given row, see Row.setZeroHeight(boolean).

        Parameters:

        rowIndex - Index of the target row, 0-based

        hidden - True to hide the target row, false to show it.

      • isRowHidden

        public boolean isRowHidden​(int rowIndex)

        Gets the visibility state of the given row. A row is hidden when it has zero height, see Row.getZeroHeight().

        Parameters:

        rowIndex - Index of the target row, 0-based

        Returns:

        true if the target row is hidden, false if it is visible.

      • read

        public void read​(File file)
                  throws IOException

        Reinitializes the component from the given Excel file.

        Parameters:

        file - Data source file. Excel format is expected.

        Throws:

        IOException - If the file can't be read, or the file is of an invalid format.

      • read

        public void read​(InputStream inputStream)
                  throws IOException

        Reinitializes the component from the given input stream. The expected format is that of an Excel file.

        Parameters:

        inputStream - Data source input stream. Excel format is expected.

        Throws:

        IOException - If handling the stream fails, or the data is in an invalid format.

      • write

        public File write​(String fileName)
                   throws FileNotFoundException,
                          IOException

        Exports current spreadsheet into a File with the given name.

        Parameters:

        fileName - The full name of the file. If the name doesn't end with '.xls' or '.xlsx', the approriate one will be appended.

        Returns:

        A File with the content of the current Workbook, In the file format of the original Workbook.

        Throws:

        FileNotFoundException - If file name was invalid

        IOException - If the file can't be written to for any reason

      • write

        public void write​(OutputStream outputStream)
                   throws IOException

        Exports current spreadsheet as an output stream.

        Parameters:

        outputStream - The target stream

        Throws:

        IOException - If writing to the stream fails

      • getRowBufferSize

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

        Size is in pixels, the default is 200.

        Returns:

        The current row buffer size

      • setRowBufferSize

        public void setRowBufferSize​(int rowBufferInPixels)

        Sets the row buffer size. Comes into effect the next time sheet is scrolled or reloaded.

        The row buffer size determines the amount of content rendered outside the top and bottom edges of the visible cell area, for smoother scrolling.

        Parameters:

        rowBufferInPixels - The amount of extra content rendered outside the top and bottom edges of the visible area.

      • getColBufferSize

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

        Size is in pixels, the default is 200.

        Returns:

        The current column buffer size

      • setColBufferSize

        public void setColBufferSize​(int colBufferInPixels)

        Sets the column buffer size. Comes into effect the next time sheet is scrolled or reloaded.

        The column buffer size determines the amount of content rendered outside the left and right edges of the visible cell area, for smoother scrolling.

        Parameters:

        colBufferInPixels - The amount of extra content rendered outside the left and right edges of the visible area.

      • getDefaultRowCount

        public int getDefaultRowCount()

        Gets the default row count for new sheets.

        Returns:

        The default row count for new sheets.

      • setDefaultRowCount

        public void setDefaultRowCount​(int defaultRowCount)

        Sets the default row count for new sheets.

        Parameters:

        defaultRowCount - The number of rows to give sheets that are created with the '+' button on the client side.

      • getDefaultColumnCount

        public int getDefaultColumnCount()

        Gets the default column count for new sheets.

        Returns:

        The default column count for new sheets.

      • setDefaultColumnCount

        public void setDefaultColumnCount​(int defaultColumnCount)

        Sets the default column count for new sheets.

        Parameters:

        defaultColumnCount - The number of columns to give sheets that are created with the '+' button on the client side.

      • reloadVisibleCellContents

        public void reloadVisibleCellContents()

        Call this to force the spreadsheet to reload the currently viewed cell contents. This forces reload of all: custom components (always visible and editors) from SpreadsheetComponentFactory, hyperlinks, cells' comments and cells' contents. Also updates styles for the visible area.

      • setResource

        protected void setResource​(String key,
                                   Icon icon)
      • reloadActiveSheetData

        protected void reloadActiveSheetData()

        Clears and reloads all data related to the currently active sheet.

      • loadCustomEditorOnSelectedCell

        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.

      • getVisibleSheetPOIIndex

        public int getVisibleSheetPOIIndex​(int visibleSheetIndex)

        Returns POI model based index for the given Spreadsheet sheet index.

        Parameters:

        visibleSheetIndex - Index of the sheet within this Spreadsheet, 0-based

        Returns:

        Index of the sheet within the POI model, or -1 if something went wrong. 0-based.

      • isSheetProtected

        public boolean isSheetProtected​(int poiSheetIndex)

        Gets the protection state of the sheet at the given POI index.

        Parameters:

        poiSheetIndex - Index of the target sheet within the POI model, 0-based

        Returns:

        true if the target Sheet is protected, false otherwise.

      • isActiveSheetProtected

        public boolean isActiveSheetProtected()

        Gets the protection state of the current sheet.

        Returns:

        true if the current Sheet is protected, false otherwise.

      • isCellHidden

        public boolean isCellHidden​(org.apache.poi.ss.usermodel.Cell cell)

        Gets the visibility state of the given cell.

        Parameters:

        cell - The cell to check

        Returns:

        true if the cell is hidden, false otherwise

      • isCellLocked

        public boolean isCellLocked​(org.apache.poi.ss.usermodel.Cell cell)

        Gets the locked state of the given cell.

        Parameters:

        cell - The cell to check

        Returns:

        true if the cell is locked, false otherwise

      • getRpcProxy

        protected SpreadsheetClientRpc getRpcProxy()

        Gets the RPC proxy for communication to the client side.

        Returns:

        Client RPC proxy instance

      • beforeClientResponse

        public void beforeClientResponse​(boolean initial)
      • getSpreadsheetStyleFactory

        public SpreadsheetStyleFactory getSpreadsheetStyleFactory()

        Gets the currently used style factory for this Spreadsheet.

        Returns:

        The current style factory.

      • setWorkbook

        public void setWorkbook​(org.apache.poi.ss.usermodel.Workbook workbook)

        Reloads the component with the given Workbook.

        Parameters:

        workbook - New workbook to load

      • loadCells

        protected void loadCells​(int firstRow,
                                 int firstColumn,
                                 int lastRow,
                                 int lastColumn)

        Sends data of the given cell area to client side. Data is only sent once, unless there are changes. Cells with custom components are skipped.

        Parameters:

        firstRow - Index of the starting row, 1-based

        firstColumn - Index of the starting column, 1-based

        lastRow - Index of the ending row, 1-based

        lastColumn - Index of the ending column, 1-based

      • setRowHeight

        public void setRowHeight​(int index,
                                 float height)

        Sets the row height for currently active sheet. Updates both POI model and the visible sheet.

        Parameters:

        index - Index of target row, 0-based

        height - New row height in points

      • setColumnWidth

        public void setColumnWidth​(int index,
                                   int width)

        Sets the column width in pixels (using conversion) for the currently active sheet. Updates both POI model and the visible sheet.

        Parameters:

        index - Index of target column, 0-based

        width - New column width in pixels

      • setSpreadsheetComponentFactory

        public void setSpreadsheetComponentFactory​(SpreadsheetComponentFactory customComponentFactory)

        Set a new component factory for this Spreadsheet. If a Workbook has been set, all components will be reloaded.

        Parameters:

        customComponentFactory - The new component factory to use.

      • getSpreadsheetComponentFactory

        public SpreadsheetComponentFactory getSpreadsheetComponentFactory()

        Gets the current SpreadsheetComponentFactory.

        Returns:

        The currently used component factory.

      • setPopup

        public void setPopup​(String cellAddress,
                             PopupButton popupButton)

        Sets a pop-up button to the given cell in the currently active sheet. If there is already a pop-up button in the given cell, it will be replaced.

        Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.

        Parameters:

        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.

      • setPopup

        public void setPopup​(int row,
                             int col,
                             PopupButton popupButton)

        Sets a pop-up button to the given cell in the currently active sheet. If there is already a pop-up button in the given cell, it will be replaced.

        Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.

        Parameters:

        row - Row index of target cell, 0-based

        col - Column index of target cell, 0-based

        popupButton - PopupButton to set for the target cell. Passing null here removes the pop-up button for the target cell.

      • setPopup

        public 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. If there is already a pop-up button in the given cell, it will be replaced.

        Note that if the active sheet is changed, all pop-up buttons are removed from the spreadsheet.

        Parameters:

        cellReference - Reference to the target cell

        popupButton - PopupButton to set for the target cell. Passing null here removes the pop-up button for the target cell.

      • registerTable

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

        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.

        Parameters:

        table - The table to register

      • unregisterTable

        public 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. This does not delete any table content, use deleteTable(SpreadsheetTable) to completely remove the table.

        See registerTable(SpreadsheetTable).

        Parameters:

        table - The table to unregister

      • getCellValue

        public final String getCellValue​(org.apache.poi.ss.usermodel.Cell cell)

        Returns the formatted value for the given cell, using the DataFormatter with the current locale. See DataFormatter.formatCellValue(Cell, FormulaEvaluator, ConditionalFormattingEvaluator).

        Parameters:

        cell - Cell to get the value from

        Returns:

        Formatted value

      • isGridlinesVisible

        public boolean isGridlinesVisible()

        Gets grid line visibility for the currently active sheet.

        Returns:

        True if grid lines are visible, false if they are hidden

      • setGridlinesVisible

        public void setGridlinesVisible​(boolean visible)

        Sets grid line visibility for the currently active sheet.

        Parameters:

        visible - True to show grid lines, false to hide them

      • isRowColHeadingsVisible

        public boolean isRowColHeadingsVisible()

        Gets row and column heading visibility for the currently active sheet.

        Returns:

        true if headings are visible, false if they are hidden

      • setRowColHeadingsVisible

        public void setRowColHeadingsVisible​(boolean visible)

        Sets row and column heading visibility for the currently active sheet.

        Parameters:

        visible - true to show headings, false to hide them

      • addSelectionChangeListener

        public void addSelectionChangeListener​(Spreadsheet.SelectionChangeListener listener)

        Adds the given SelectionChangeListener to this Spreadsheet.

        Parameters:

        listener - Listener to add.

      • addCellValueChangeListener

        public void addCellValueChangeListener​(Spreadsheet.CellValueChangeListener listener)

        Adds the given CellValueChangeListener to this Spreadsheet.

        Parameters:

        listener - Listener to add.

      • addFormulaValueChangeListener

        public void addFormulaValueChangeListener​(Spreadsheet.FormulaValueChangeListener listener)

        Adds the given FormulaValueChangeListener to this Spreadsheet.

        Parameters:

        listener - Listener to add.

      • removeSelectionChangeListener

        public void removeSelectionChangeListener​(Spreadsheet.SelectionChangeListener listener)

        Removes the given SelectionChangeListener from this Spreadsheet.

        Parameters:

        listener - Listener to remove.

      • removeCellValueChangeListener

        public void removeCellValueChangeListener​(Spreadsheet.CellValueChangeListener listener)

        Removes the given CellValueChangeListener from this Spreadsheet.

        Parameters:

        listener - Listener to remove.

      • addProtectedEditListener

        public void addProtectedEditListener​(Spreadsheet.ProtectedEditListener listener)

        Add listener for when an attempt to modify a locked cell has been made.

        Parameters:

        listener - The listener to add.

      • removeProtectedEditListener

        public void removeProtectedEditListener​(Spreadsheet.ProtectedEditListener listener)

        Removes the given ProtectedEditListener.

        Parameters:

        listener - The listener to remove.

      • createFreezePane

        public void createFreezePane​(int rowSplit,
                                     int colSplit)

        Creates or removes a freeze pane from the currently active sheet. If both colSplit and rowSplit are zero then the existing freeze pane is removed.

        Parameters:

        rowSplit - Vertical position of the split, 1-based row index

        colSplit - Horizontal position of the split, 1-based column index

      • removeFreezePane

        public void removeFreezePane()

        Removes the freeze pane from the currently active sheet if one is present.

      • getSelectedCellReferences

        public Set<org.apache.poi.ss.util.CellReference> getSelectedCellReferences()

        Gets all the currently selected cells.

        Returns:

        References to all currently selected cells.

      • addSheetChangeListener

        public void addSheetChangeListener​(Spreadsheet.SheetChangeListener listener)

        Adds the given SheetChangeListener to this Spreadsheet.

        Parameters:

        listener - Listener to add

      • removeSheetChangeListener

        public void removeSheetChangeListener​(Spreadsheet.SheetChangeListener listener)

        Removes the given SheetChangeListener from this Spreadsheet.

        Parameters:

        listener - Listener to remove

      • onConnectorInit

        protected void onConnectorInit()

        This is called when the client-side connector has been initialized.

      • reload

        public void reload()

        Reloads all data from the current spreadsheet and performs a full re-render.

        Functionally same as calling setWorkbook(Workbook) with getWorkbook() parameter.

      • setStatusLabelValue

        public void setStatusLabelValue​(String value)

        Sets the content of the status label.

        Parameters:

        value - The new content. Can not be HTML.

      • getStatusLabelValue

        public String getStatusLabelValue()

        Gets the content of the status label

        Returns:

        Current content of the status label.

      • setSelection

        public void setSelection​(int row,
                                 int col)

        Selects the cell at the given coordinates

        Parameters:

        row - Row index, 0-based

        col - Column index, 0-based

      • setSelectionRange

        public void setSelectionRange​(int row1,
                                      int col1,
                                      int row2,
                                      int col2)

        Selects the given range, using the cell at row1 and col1 as an anchor.

        Parameters:

        row1 - Index of the first row of the area, 0-based

        col1 - Index of the first column of the area, 0-based

        row2 - Index of the last row of the area, 0-based

        col2 - Index of the last column of the area, 0-based

      • setSelection

        public 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. Note that scatter charts, if present, use formulas that may contain named ranges.

        Parameters:

        selectionRange - The wanted range, e.g. "A3" or "B3:C5"

      • reset

        public void reset()

        Disposes the current Workbook, if any, and loads a new empty XSLX Workbook. Note: Discards all data. Be sure to write out the old Workbook if needed.

      • getDefaultPercentageFormat

        public String getDefaultPercentageFormat()

        Returns the formatting string that is used when a user enters percentages into the Spreadsheet.

        Default is "0.00%".

        Returns:

        The formatting applied to percentage values when entered by the user

      • setDefaultPercentageFormat

        public void setDefaultPercentageFormat​(String defaultPercentageFormat)

        Sets the formatting string that is used when a user enters percentages into the Spreadsheet.

        Default is "0.00%".

      • setCommentAuthorProvider

        public void setCommentAuthorProvider​(Spreadsheet.CommentAuthorProvider commentAuthorProvider)

        Sets the given CommentAuthorProvider to this Spreadsheet.

        Parameters:

        commentAuthorProvider - New provider

      • getCommentAuthorProvider

        public Spreadsheet.CommentAuthorProvider getCommentAuthorProvider()

        Gets the CommentAuthorProvider currently set to this Spreadsheet.

        Returns:

        Current provider or null if not set.

      • editCellComment

        public void editCellComment​(org.apache.poi.ss.util.CellReference cr)

        Triggers editing of the cell comment in the given cell reference. Note that the cell must have a previously set cell comment in order to be able to edit it.

        Parameters:

        cr - Reference to the cell containing the comment to edit

      • setFunctionBarVisible

        public void setFunctionBarVisible​(boolean functionBarVisible)

        Sets the visibility of the top function bar. By default the bar is visible.

        Parameters:

        functionBarVisible - True to show the top bar, false to hide it.

      • isFunctionBarVisible

        public boolean isFunctionBarVisible()

        Gets the visibility of the top function bar. By default the bar is visible.

        Returns:

        True if the function bar is visible, false otherwise.

      • setSheetSelectionBarVisible

        public void setSheetSelectionBarVisible​(boolean sheetSelectionBarVisible)

        Sets the visibility of the bottom sheet selection bar. By default the bar is visible.

        Parameters:

        sheetSelectionBarVisible - True to show the sheet selection bar, false to hide it.

      • isSheetSelectionBarVisible

        public boolean isSheetSelectionBarVisible()

        Gets the visibility of the bottom sheet selection bar. By default the bar is visible.

        Returns:

        True if the sheet selection bar is visible, false otherwise.

      • setReportStyle

        public void setReportStyle​(boolean reportStyle)

        Enables or disables the report style. When enabled, the top and bottom bars of Spreadsheet will be hidden.

        Parameters:

        reportStyle - True to hide both toolbars, false to show them.

      • isReportStyle

        public boolean isReportStyle()

        Gets the state of the report style.

        Returns:

        True if report style is enabled, false otherwise.

      • setInvalidFormulaErrorMessage

        public void setInvalidFormulaErrorMessage​(String invalidFormulaErrorMessage)
      • getTabIndex

        public int getTabIndex()

        Description copied from interface: Focusable

        Gets the tabindex in the component. The tabIndex indicates if its element can be focused, and if/where it participates in sequential keyboard navigation.

        If there's no such attribute set, it returns the default setting for the element, which depends on the element and on the browser. If the attribute cannot be parsed to int, then an IllegalStateException is thrown.

        Specified by:

        getTabIndex in interface Focusable

        Returns:

        the tabindex attribute, or 0 if none

        See Also:

        tabindex at MDN

      • setTabIndex

        public void setTabIndex​(int tabIndex)

        Description copied from interface: Focusable

        Sets the tabindex attribute in the component. The tabIndex indicates if its element can be focused, and if/where it participates in sequential keyboard navigation:

        • A negative value (usually tabindex = -1 means that the component should be focusable, but should not be reachable via sequential keyboard navigation.
        • tabindex = 0 means that the component should be focusable in sequential keyboard navigation, but its order is defined by the document's source order.
        • A positive value means the component should be focusable in sequential keyboard navigation, with its order defined by the value of the number. That is, tabindex = 4 would be focused before tabindex = 5, but after tabindex = 3. If multiple components share the same positive tabindex value, their order relative to each other follows their position in the document source.

        Specified by:

        setTabIndex in interface Focusable

        Parameters:

        tabIndex - the tabindex attribute

        See Also:

        tabindex at MDN

      • setGroupingCollapsed

        protected void setGroupingCollapsed​(boolean isCols,
                                            int index,
                                            boolean collapsed)

        Controls if a column group is collapsed or not.

        Parameters:

        isCols - true when collapsing columns, false when collapsing rows

        index - A column that is part of the group, 0-based

        collapsed - If the group should be collapsed or not

      • levelHeaderClicked

        protected void levelHeaderClicked​(boolean isCols,
                                          int level)

        Called when a grouping level header is clicked

        Parameters:

        isCols - true if the user clicked on cols, false for row level headers

        level - which level the user clicked

      • getMinimumRowHeightForComponents

        public int getMinimumRowHeightForComponents()

        Get the minimum row heigth in points for the rows that contain custom components

        Returns:

        the minimum row heigths in points

      • setMinimumRowHeightForComponents

        public void setMinimumRowHeightForComponents​(int minimumRowHeightForComponents)

        Set the minimum row heigth in points for the rows that contain custom components. If set to a small value, it might cause some components like checkboxes to be cut off

        Parameters:

        minimumRowHeightForComponents - the minimum row height in points

      • getLocale

        public Locale getLocale()

        Description copied from class: Component

        Gets the locale for this component.

        It returns the UI locale if it has been set. If there is no UI locale available then it tries to use the first locale provided by the I18NProvider. If there is no any provided locale then the default locale is used.

        Overrides:

        getLocale in class Component

        Returns:

        the component locale