Package io.keikai.ui

Class Spreadsheet

java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
io.keikai.ui.Spreadsheet
All Implemented Interfaces:
Serializable, Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.AfterCompose, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl

public class Spreadsheet extends org.zkoss.zul.impl.XulElement implements Serializable, org.zkoss.zk.ui.ext.AfterCompose
Spreadsheet is a rich ZK Component to handle EXCEL like behavior, it reads the data from a data model(SBook) and interact with this model by event.
You can assign a Book by setBook(Book) or just set the .xls file location by setSrc(String). You can also set two attributes to restrict max rows and columns to show on client side by setMaxVisibleRows(int) and setMaxVisibleColumns(int).
To use Spreadsheet in .zul file, just use <spreadsheet/> tag like any other ZK Components.
An simplest example :
   &nbsp ;<spreadsheet src= "/WEB-INF/xls/my.xls" maxrows="300" maxcolumns="80" 
        
height="400px" width="90%" />
Author:
dennischen, jumperchen
See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrl

    Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

    org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     

    Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    _zclass

    Fields inherited from interface org.zkoss.zk.ui.Component

    APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE

    Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

    AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Inserts the specified button at the specified position in the buttons list.
    boolean
    Adds toolbar button to the end of the buttons.
    void
     
    void
    autoFitRowHeight(int row, int col)
    Adjust specified row's height of the currently-selected sheet according to the specified cell's content.
    void
    Call this method to clear client side cache for a Sheet and fine tune data loading speed.
    void
    Clear current Server Clipboard
    void
    Clears the tracing.
    void
    disableUserAction(AuxAction action, boolean disabled)
    Sets the AuxAction disabled
    void
    Retrieve client side spreadsheet focus.The cell focus and selection will keep at last status.
    void
    focusTo(int row, int column)
    Retrieve client side spreadhsheet focus, move cell focus to position (row,column) and also scroll the cell to into visible view.
    Return all selection rectangle only if onCellSelection event listener is registered.
    Returns the book model of this Spreadsheet.
    Return current cell(row,column) focus position.
    Internal used only
    Return current Server Clipboard
     
    getColumntitle(int index)
    Get Column title of given index, it returns column name depends on following condition
    1.if there is a custom column title assign on this spreadsheet on index, then return custom value
    2.if there is a custom column title assign on selected sheet on index, the return custom value
    3.return default column String, for example index 0 become "A", index 9 become "J"
    Get the column titles Map object, modification of return object doesn't cause any update.
    int
    Gets the default column width of the selected sheet
    int
    Returns the maximum visible number of columns of the currently selected sheet.
    int
    Returns the maximum visible number of rows of the currently selected sheet.
     
    Return current highlight rectangle.
    Gets the importer that import the file in the specified src ( getSrc()) to Book data model.
    int
    Gets the left head panel width
    int
    Returns the max rendered cell size
    int
    Returns the maximum visible number of columns of this spreadsheet.
    int
    Returns the maximum visible number of rows of this spreadsheet.
    int
     
    int
     
    int
    Gets the default row height of the selected sheet
     
    getRowtitle(int index)
    Get Row title of given index, it returns row name depends on following condition
    1.if there is a custom row title assign on this spreadsheet on index, then return custom value
    2.if there is a custom row title assign on selected sheet on index, the return custom value
    3.return default row index+1 String, for example index 0 become "1", index 9 become "10"
    Get the row titles Map object, modification of the return object doesn't cause any update.
    Returns the book model of this Spreadsheet.
    Gets the selected sheet, the default selected sheet is first sheet.
     
    Gets the selected sheet, the default selected sheet is first visible sheet.
    Return current selection rectangle only if onCellSelection event listener is registered.
    int
    Returns the max visible columns of the specified sheet
    int
    Returns the max visible rows of the specified sheet
    Returns the src location of book model.
    Returns all toolbar buttons (read only).
    int
    Gets the top head panel height
     
    Gets the user action manager, then you can register/override your custom action by call UserActionManager.registerHandler(String, String, UserActionHandler)
    boolean
    insertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)
     
    void
     
    boolean
    Returns whether client cache disabled or not
    boolean
    Returns whether to close dropdown menu on scroll; default to false.
    boolean
    Returns true if hide column head of this spread sheet; default to false.
    boolean
    Returns true if hide row head of this spread sheet; default to false.
    boolean
    Returns true if keep the cell selection box when lost focus; default to false.
    boolean
    Returns whether the component is in read-ony mode or not.
    boolean
    Returns whether show the add column button in sheetbar.
    boolean
    Returns whether show the add row button in sheetbar.
    boolean
    Returns whether to show ContextMenu or not
    boolean
    Returns whether show formula bar
    boolean
    Returns whether show sheetbar
    boolean
    Returns whether show ContextMenu in sheet tab
    boolean
    Returns whether shows toolbar
    boolean
    Returns whether to show zero values or not
    void
    moveEditorFocus(String id, String name, String color, int row, int col)
    Add and move other editor's focus
    protected SpreadsheetCtrl
     
    void
    NotifyChange the currently loaded area and freeze area if exists.
    void
    NotifyChange the currently visible area and freeze area if exists.
    void
    onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
     
    void
    onPageDetached(org.zkoss.zk.ui.Page page)
     
    static Object[]
    parseLinkAddress(Book book, String linkAddress)
     
    void
    Remove editor's focus on specified name
    boolean
    Removes the button at the specified position in this buttons list.
    boolean
    Removes the first occurrence of the given button instance in the buttons list.
    boolean
    Removes the first occurrence of the given button instance in the buttons list.
    boolean
    Removes the first occurrence of the given key in the buttons list.
    protected void
    renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)
     
    void
    response(String key, org.zkoss.zk.au.AuResponse response)
     
    void
    service(org.zkoss.zk.au.AuRequest request, boolean everError)
    Processes an AU request.
    void
    setAutofitColumnWidth(SSheet sheet, int column)
    AutoFit a single column width according to its data size.
    void
    setAutofitColumnWidth(SSheet sheet, int fromColumn, int toColumn)
    AutoFit multiple columns width according to each one's data size from the fromColumn to the toColumn.
    void
    setBook(Book book)
    Sets the book data model of this spread sheet.
    void
    Sets the cell focus position.(this method doesn't focus the spreadsheet.) In general, if you set a cell focus, you also set the selection by setSelection(AreaRef); And if you want to get the focus back to spreadsheet, call focus() to retrieve focus.
    void
    setClientCacheDisabled(boolean clientCacheDisabled)
    Sets to disable client cache.
    void
    Set current Server Clipboard
    void
    setCloseDropdownOnScroll(boolean closeDropdownOnScroll)
    Sets whether to close dropdown menu on scroll.
    void
    Sets the customized titles which split by ','.
    void
    Sets the customized titles of column header.
    void
    setColumnwidth(int columnWidth)
    Sets the default column width of the selected sheet
    void
    setCtrlKeys(String ctrlKeys)
     
    void
    setDraggable(String draggable)
    Don't call this, the spreadsheet is not draggable.
    void
    setHidecolumnhead(boolean hide)
    Sets true to hide the column head of this spread sheet.
    void
    setHiderowhead(boolean hide)
    Sets true to hide the row head of this spread sheet.
    void
    setHighlight(AreaRef highlight)
    Sets the highlight rectangle or sets a null value to hide it.
    void
    Whether ignore row's autoHeight calculation.
    void
     
    void
    setKeepCellSelection(boolean keep)
    Sets true to keep the cell selection box when lost focus.
    void
    setLeftheadwidth(int leftWidth)
    Sets the left head panel width, must large then 0.
    void
    setMaxRenderedCellSize(int maxRenderedCellSize)
    Sets the max rendered cell size.
    void
    setMaxVisibleColumns(int maxcols)
    Sets the maximum visible number of columns of this spreadsheet.
    void
    setMaxVisibleRows(int maxrows)
    Sets the maximum visible number of rows of this spreadsheet.
    void
     
    void
     
    void
    setReadOnly(boolean readOnly)
    Sets whether to enable this component as read-only mode or not.
    void
    setRowheight(int rowHeight)
    Sets the default row height of the selected sheet
    void
    Sets the customized titles which split by ','.
    void
    setRowtitles(Map titles)
    Sets the customized titles of row header.
    void
    Sets the book data model of this spread sheet.
    void
    Sets the selected sheet by a name
    void
    Sets the selection rectangle.
    void
    setSelection(Set<AreaRef> selection)
    Sets the selection rectangle.
    void
    setSheetMaxVisibleColumns(SSheet sheet, int maxColumns)
    Sets the max visibles columns of the specified sheet.
    void
    setSheetMaxVisibleRows(SSheet sheet, int maxRows)
    Sets the max visible rows of the specified sheet
    void
    setShowAddColumn(boolean showAddColumn)
    Sets whether show the add column button in sheetbar.
    void
    setShowAddRow(boolean showAddRow)
    Sets whether show the add row button in sheetbar.
    void
    setShowContextMenu(boolean showContextMenu)
    Sets whether show ContextMenu or not
    void
    setShowFormulabar(boolean showFormulabar)
    Sets whether show formula bar or not
    void
    setShowSheetbar(boolean showSheetbar)
    Sets whether show sheetbar or not
    void
    setShowSheetTabContextMenu(boolean showSheetTabContextMenu)
    Sets whether show ContextMenu or not
    void
    setShowToolbar(boolean showToolbar)
    Sets whether show toolbar or not Default: false
    void
    Sets the src location of the book data model to be imported into spreadsheet.
    void
    setTopheadheight(int topHeight)
    Sets the top head panel height, must large then 0.
    void
    Under collaboration edit mode, Spreadsheet renders multiple selection boxes in a sheet.
    void
    smartUpdate(String attr, Object value)
     
    void
    smartUpdate(String attr, Object value, boolean append)
     
    void
    traceDependents(Sheet sheet, CellRef cellRef)
    Trace the dependents of the reference.
    void
    tracePrecedents(Sheet sheet, CellRef cellRef)
    Trace the precedent of the reference.

    Methods inherited from class org.zkoss.zul.impl.XulElement

    clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes

    Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

    addSclass, evalCSSFlex, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly

    Methods inherited from class org.zkoss.zk.ui.AbstractComponent

    addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • Spreadsheet

      public Spreadsheet()
  • Method Details

    • traceDependents

      public void traceDependents(Sheet sheet, CellRef cellRef)
      Trace the dependents of the reference.
      Parameters:
      sheet -
      cellRef -
      Since:
      5.6.0
    • tracePrecedents

      public void tracePrecedents(Sheet sheet, CellRef cellRef)
      Trace the precedent of the reference.
      Parameters:
      sheet -
      cellRef -
      Since:
      5.6.0
    • clearTrace

      public void clearTrace()
      Clears the tracing.
      Since:
      5.6.0
    • getUserActionManager

      public UserActionManager getUserActionManager()
      Gets the user action manager, then you can register/override your custom action by call UserActionManager.registerHandler(String, String, UserActionHandler)
      Returns:
      UserActionManager or null if doesn't support to override
      Since:
      3.0.0
    • setCtrlKeys

      public void setCtrlKeys(String ctrlKeys)
      Overrides:
      setCtrlKeys in class org.zkoss.zul.impl.XulElement
    • setMaxRenderedCellSize

      public void setMaxRenderedCellSize(int maxRenderedCellSize)
      Sets the max rendered cell size. When rendered cell size greater then this limit, client side will prune extra cells (DOM Element).
      Parameters:
      maxRenderedCellSize -
    • getMaxRenderedCellSize

      public int getMaxRenderedCellSize()
      Returns the max rendered cell size
      Returns:
      int maxRenderedCellSize
    • isClientCacheDisabled

      public boolean isClientCacheDisabled()
      Returns whether client cache disabled or not
      Returns:
    • isShowZeroValues

      public boolean isShowZeroValues()
      Returns whether to show zero values or not
    • setClientCacheDisabled

      public void setClientCacheDisabled(boolean clientCacheDisabled)
      Sets to disable client cache. Default is false
      Parameters:
      clientCacheDisabled -
    • isCloseDropdownOnScroll

      public boolean isCloseDropdownOnScroll()
      Returns whether to close dropdown menu on scroll; default to false.
      Returns:
      boolean
      Since:
      6.3.0
    • setCloseDropdownOnScroll

      public void setCloseDropdownOnScroll(boolean closeDropdownOnScroll)
      Sets whether to close dropdown menu on scroll. Default is false.
      Parameters:
      closeDropdownOnScroll -
      Since:
      6.3.0
    • setDraggable

      public void setDraggable(String draggable)
      Don't call this, the spreadsheet is not draggable.
      Overrides:
      setDraggable in class org.zkoss.zk.ui.HtmlBasedComponent
      Throws:
      UnsupportedOperationException - if this method is called.
    • getSBook

      public SBook getSBook()
      Returns the book model of this Spreadsheet. If you call this method at first time and the book has not assigned by setSBook(SBook), this will create a new model depends on src;
      Returns:
      the book model of this spreadsheet.
    • setSBook

      public void setSBook(SBook book)
      Sets the book data model of this spread sheet.
      Parameters:
      book - the book data model.
    • getSelectedSSheet

      public SSheet getSelectedSSheet()
      Gets the selected sheet, the default selected sheet is first visible sheet.
      Returns:
      #SSheet
    • getSrc

      public String getSrc()
      Returns the src location of book model. This src is used by the specified importer to create the book data model of this spread sheet.
      Returns:
      the src location
    • setSrc

      public void setSrc(String src)
      Sets the src location of the book data model to be imported into spreadsheet. A specified importer (getImporter()) will use this src to create the book data model.
      Parameters:
      src - the book src location
    • setSelectedSheet

      public void setSelectedSheet(String name)
      Sets the selected sheet by a name
      Parameters:
      name - the name of spreadsheet to be selected.
    • setPreloadRowSize

      public void setPreloadRowSize(int size)
    • getPreloadRowSize

      public int getPreloadRowSize()
    • setPreloadColumnSize

      public void setPreloadColumnSize(int size)
    • getPreloadColumnSize

      public int getPreloadColumnSize()
    • isHiderowhead

      public boolean isHiderowhead()
      Returns true if hide row head of this spread sheet; default to false.
      Returns:
      true if hide row head of this spread sheet; default to false.
    • setHiderowhead

      public void setHiderowhead(boolean hide)
      Sets true to hide the row head of this spread sheet.
      Parameters:
      hide - true to hide the row head of this spread sheet.
    • isHidecolumnhead

      public boolean isHidecolumnhead()
      Returns true if hide column head of this spread sheet; default to false.
      Returns:
      true if hide column head of this spread sheet; default to false.
    • setHidecolumnhead

      public void setHidecolumnhead(boolean hide)
      Sets true to hide the column head of this spread sheet.
      Parameters:
      hide - true to hide the row head of this spread sheet.
    • setColumntitles

      public void setColumntitles(Map titles)
      Sets the customized titles of column header.
      Parameters:
      titles - a map for customized column titles, the key of column must be Integer object.
    • getColumntitles

      public Map getColumntitles()
      Get the column titles Map object, modification of return object doesn't cause any update.
      Returns:
      Map object of customized column names
    • setColumntitles

      public void setColumntitles(String titles)
      Sets the customized titles which split by ','. For example: "name,title,age" or "name,,age" , an empty string means use default column title. This method will split the input string to a Map with sequence index from 0, then call setColumntitles(Map)

      Note: this method will always invoke invalidate()

      Parameters:
      titles - the column titles
    • setRowtitles

      public void setRowtitles(Map titles)
      Sets the customized titles of row header.
      Parameters:
      titles - map for customized column titles, the key of column must be Integer object.
    • getRowtitles

      public Map getRowtitles()
      Get the row titles Map object, modification of the return object doesn't cause any update.
      Returns:
      Map object of customized row names
    • setRowtitles

      public void setRowtitles(String titles)
      Sets the customized titles which split by ','. For example: "name,title,age" or "name,,age" , an empty string means use default row title. This method will split the input string to a Map with sequence index from 0, then call setRowtitles(Map)

      Note: this method will always invoke invalidate()

      Parameters:
      titles - the row titles
    • getRowheight

      public int getRowheight()
      Gets the default row height of the selected sheet
      Returns:
      default value depends on selected sheet
    • setRowheight

      public void setRowheight(int rowHeight)
      Sets the default row height of the selected sheet
      Parameters:
      rowHeight - the row height
    • getColumnwidth

      public int getColumnwidth()
      Gets the default column width of the selected sheet
      Returns:
      default value depends on selected sheet
    • setColumnwidth

      public void setColumnwidth(int columnWidth)
      Sets the default column width of the selected sheet
      Parameters:
      columnWidth - the default column width
    • getLeftheadwidth

      public int getLeftheadwidth()
      Gets the left head panel width
      Returns:
      default value is 36
    • setLeftheadwidth

      public void setLeftheadwidth(int leftWidth)
      Sets the left head panel width, must large then 0.
      Parameters:
      leftWidth - leaf header width
    • getTopheadheight

      public int getTopheadheight()
      Gets the top head panel height
      Returns:
      default value is 20
    • setTopheadheight

      public void setTopheadheight(int topHeight)
      Sets the top head panel height, must large then 0.
      Parameters:
      topHeight - top header height
    • setShowToolbar

      public void setShowToolbar(boolean showToolbar)
      Sets whether show toolbar or not Default: false
      Parameters:
      showToolbar - true to show toolbar
    • isShowToolbar

      public boolean isShowToolbar()
      Returns whether shows toolbar
      Returns:
      boolean
    • setShowFormulabar

      public void setShowFormulabar(boolean showFormulabar)
      Sets whether show formula bar or not
      Parameters:
      showFormulabar - true if want to show formula bar
    • isShowFormulabar

      public boolean isShowFormulabar()
      Returns whether show formula bar
    • setShowSheetbar

      public void setShowSheetbar(boolean showSheetbar)
      Sets whether show sheetbar or not
      Parameters:
      showSheetbar - true if want to show sheet tab panel
    • isShowSheetbar

      public boolean isShowSheetbar()
      Returns whether show sheetbar
    • setShowContextMenu

      public void setShowContextMenu(boolean showContextMenu)
      Sets whether show ContextMenu or not
      Parameters:
      showContextMenu -
    • isShowContextMenu

      public boolean isShowContextMenu()
      Returns whether to show ContextMenu or not
    • isShowSheetTabContextMenu

      public boolean isShowSheetTabContextMenu()
      Returns whether show ContextMenu in sheet tab
      Returns:
    • setShowSheetTabContextMenu

      public void setShowSheetTabContextMenu(boolean showSheetTabContextMenu)
      Sets whether show ContextMenu or not
      Parameters:
      showSheetTabContextMenu -
    • renderProperties

      protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws IOException
      Overrides:
      renderProperties in class org.zkoss.zul.impl.XulElement
      Throws:
      IOException
    • getColumntitle

      public String getColumntitle(int index)
      Get Column title of given index, it returns column name depends on following condition
      1.if there is a custom column title assign on this spreadsheet on index, then return custom value
      2.if there is a custom column title assign on selected sheet on index, the return custom value
      3.return default column String, for example index 0 become "A", index 9 become "J"
      Returns:
      column name
    • getRowtitle

      public String getRowtitle(int index)
      Get Row title of given index, it returns row name depends on following condition
      1.if there is a custom row title assign on this spreadsheet on index, then return custom value
      2.if there is a custom row title assign on selected sheet on index, the return custom value
      3.return default row index+1 String, for example index 0 become "1", index 9 become "10"
      Parameters:
      index - row index
      Returns:
      row name
    • getSelection

      public AreaRef getSelection()
      Return current selection rectangle only if onCellSelection event listener is registered. The returned value is a clone copy of current selection status. Default Value:(0,0,0,0)
      Returns:
      current selection (the last one if multiple)
    • getAllSelection

      public Set<AreaRefWithType> getAllSelection()
      Return all selection rectangle only if onCellSelection event listener is registered. The returned value is a clone copy of current selection status.
      Returns:
      all selection
      Since:
      6.0.0
    • setSelection

      public void setSelection(AreaRef sel)
      Sets the selection rectangle. In general, if you set a selection, you must also set the focus by setCellFocus(CellRef);. And, if you want to get the focus back to spreadsheet, call focus() after set selection.
      Parameters:
      sel - the selection rect
    • setSelection

      public void setSelection(Set<AreaRef> selection)
      Sets the selection rectangle. In general, if you set a selection, you must also set the focus by setCellFocus(CellRef);. And, if you want to get the focus back to spreadsheet, call focus() after set selection.
      Parameters:
      selection - the multiple selection rect
      Since:
      6.0.0
    • getHighlight

      public AreaRef getHighlight()
      Return current highlight rectangle. the returned value is a clone copy of current highlight status. Default Value: null
      Returns:
      current highlight
    • setHighlight

      public void setHighlight(AreaRef highlight)
      Sets the highlight rectangle or sets a null value to hide it.
      Parameters:
      highlight - the highlight rect
    • setReadOnly

      public void setReadOnly(boolean readOnly)
      Sets whether to enable this component as read-only mode or not. If true, the priority is higher than sheet's protection setting.
      Parameters:
      readOnly - true to be read only mode.
      Since:
      5.6.0
    • isReadOnly

      public boolean isReadOnly()
      Returns whether the component is in read-ony mode or not. Default: false
      Since:
      5.6.0
    • getCellFocus

      public CellRef getCellFocus()
      Return current cell(row,column) focus position. you can get the row by CellRef.getRow(), get the column by CellRef.getColumn() . The returned value is a copy of current focus status. Default Value:(0,0)
      Returns:
      current focus
    • setCellFocus

      public void setCellFocus(CellRef focus)
      Sets the cell focus position.(this method doesn't focus the spreadsheet.) In general, if you set a cell focus, you also set the selection by setSelection(AreaRef); And if you want to get the focus back to spreadsheet, call focus() to retrieve focus.
      Parameters:
      focus - the cell focus position
    • getRowPosition

      public HeaderPositionHelper getRowPosition(SSheet sheet)
    • getColumnPosition

      public HeaderPositionHelper getColumnPosition(SSheet sheet)
    • getExtraCtrl

      public Object getExtraCtrl()
      Specified by:
      getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      getExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent
    • newExtraCtrl

      protected SpreadsheetCtrl newExtraCtrl()
    • invalidate

      public void invalidate()
      Specified by:
      invalidate in interface org.zkoss.zk.ui.Component
      Overrides:
      invalidate in class org.zkoss.zk.ui.AbstractComponent
    • focus

      public void focus()
      Retrieve client side spreadsheet focus.The cell focus and selection will keep at last status. It is useful if you want get focus back to spreadsheet after do some outside processing, for example after user click a outside button or menu item.
      Overrides:
      focus in class org.zkoss.zk.ui.HtmlBasedComponent
    • focusTo

      public void focusTo(int row, int column)
      Retrieve client side spreadhsheet focus, move cell focus to position (row,column) and also scroll the cell to into visible view.
      Parameters:
      row - row of cell to move
      column - column of cell to move
    • getSelectedSheetName

      public String getSelectedSheetName()
    • disableUserAction

      public void disableUserAction(AuxAction action, boolean disabled)
      Sets the AuxAction disabled
      Parameters:
      action -
      disabled -
    • addToolbarButton

      public boolean addToolbarButton(ToolbarButton btn)
      Adds toolbar button to the end of the buttons.
      Parameters:
      btn -
      Returns:
      true if success.
      Since:
      5.0.0
    • addToolbarButton

      public void addToolbarButton(int index, ToolbarButton btn)
      Inserts the specified button at the specified position in the buttons list. Shifts the button currently at that position (if any) and any subsequent buttons to the right (adds one to their indices).
      Parameters:
      index - index at which the specified element is to be inserted
      btn -
    • removeToolbarButton

      public boolean removeToolbarButton(ToolbarButton btn)
      Removes the first occurrence of the given button instance in the buttons list.
      Parameters:
      btn -
      Returns:
      Since:
      5.0.0
    • removeToolbarButton

      public boolean removeToolbarButton(String key)
      Removes the first occurrence of the given key in the buttons list.
      Parameters:
      key - the button's key
      Returns:
      Since:
      5.0.0
    • removeToolbarButton

      public boolean removeToolbarButton(AuxAction btn)
      Removes the first occurrence of the given button instance in the buttons list.
      Parameters:
      btn -
      Returns:
      Since:
      5.1.0
    • removeToolbarButton

      public boolean removeToolbarButton(int index)
      Removes the button at the specified position in this buttons list.
      Parameters:
      index -
      Returns:
    • getToolbarButtons

      public List<ToolbarButton> getToolbarButtons()
      Returns all toolbar buttons (read only).
      Returns:
      Since:
      5.0.0
    • insertBefore

      public boolean insertBefore(org.zkoss.zk.ui.Component newChild, org.zkoss.zk.ui.Component refChild)
      Specified by:
      insertBefore in interface org.zkoss.zk.ui.Component
      Overrides:
      insertBefore in class org.zkoss.zk.ui.AbstractComponent
    • removeEditorFocus

      public void removeEditorFocus(String id)
      Remove editor's focus on specified name
    • moveEditorFocus

      public void moveEditorFocus(String id, String name, String color, int row, int col)
      Add and move other editor's focus
    • setUserName

      public void setUserName(String name)
      Under collaboration edit mode, Spreadsheet renders multiple selection boxes in a sheet. Each selection box shows its user name when you hover on it except your owned one.
      Parameters:
      name - a name that shows with a selection box on other Spreadsheet
    • service

      public void service(org.zkoss.zk.au.AuRequest request, boolean everError)
      Processes an AU request. It is invoked internally.

      Default: in addition to what are handled by HtmlBasedComponent.service(AuRequest, boolean), it also handles onChange.

      Specified by:
      service in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      service in class org.zkoss.zk.ui.HtmlBasedComponent
    • smartUpdate

      public void smartUpdate(String attr, Object value)
      Overrides:
      smartUpdate in class org.zkoss.zk.ui.AbstractComponent
    • smartUpdate

      public void smartUpdate(String attr, Object value, boolean append)
      Overrides:
      smartUpdate in class org.zkoss.zk.ui.AbstractComponent
    • response

      public void response(String key, org.zkoss.zk.au.AuResponse response)
      Overrides:
      response in class org.zkoss.zk.ui.AbstractComponent
    • afterCompose

      public void afterCompose()
      Specified by:
      afterCompose in interface org.zkoss.zk.ui.ext.AfterCompose
    • onPageAttached

      public void onPageAttached(org.zkoss.zk.ui.Page newpage, org.zkoss.zk.ui.Page oldpage)
      Specified by:
      onPageAttached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageAttached in class org.zkoss.zk.ui.AbstractComponent
    • onPageDetached

      public void onPageDetached(org.zkoss.zk.ui.Page page)
      Specified by:
      onPageDetached in interface org.zkoss.zk.ui.sys.ComponentCtrl
      Overrides:
      onPageDetached in class org.zkoss.zk.ui.AbstractComponent
    • getBook

      public Book getBook()
      Returns the book model of this Spreadsheet. If you call this method at first time and the book has not assigned by setBook(Book), this will create a new model depends on src;
      Returns:
      the book model of this spread sheet.
    • setBook

      public void setBook(Book book)
      Sets the book data model of this spread sheet.
      Parameters:
      book - the book data model.
    • setAutofitColumnWidth

      public void setAutofitColumnWidth(SSheet sheet, int column)
      AutoFit a single column width according to its data size. No resize when the whole column without any content.
      Parameters:
      sheet -
      column -
      Since:
      5.7.0
      See Also:
    • setAutofitColumnWidth

      public void setAutofitColumnWidth(SSheet sheet, int fromColumn, int toColumn)
      AutoFit multiple columns width according to each one's data size from the fromColumn to the toColumn. No resize when the whole column has no content.
      Note: be aware of that in different JDK vendor, version, or OS, the FontMetrics calculates a different width value of the same text, so the result on UI may look different when the server is running on these differences which are mentioned early.
      Parameters:
      sheet -
      fromColumn - the start column to autofit width
      toColumn - the end column to autofit width
      Since:
      5.7.0
    • autoFitRowHeight

      public void autoFitRowHeight(int row, int col)
      Adjust specified row's height of the currently-selected sheet according to the specified cell's content. Since it calculates the height at client side, it takes effect only when the specified cell is rendered in a browser, but the resulting height is more accurate than CellOperationUtil.getAutoFitHeight(Sheet, int, int). If the target cell is a merged cell, please specify its left-top corner cell.
      Parameters:
      row - index of row
      col - index of column
      Since:
      5.11.0
    • getSelectedSheet

      public Sheet getSelectedSheet()
      Gets the selected sheet, the default selected sheet is first sheet.
      Returns:
      #Sheet
    • getMaxVisibleColumns

      public int getMaxVisibleColumns()
      Returns the maximum visible number of columns of this spreadsheet. You can assign new numbers by calling setMaxVisibleColumns(int).
      Returns:
      the maximum visible number of columns
      Since:
      3.0.0
    • getMaxVisibleRows

      public int getMaxVisibleRows()
      Returns the maximum visible number of rows of this spreadsheet. You can assign new number by calling setMaxVisibleRows(int).
      Returns:
      the maximum visible number of rows of the currently selected sheet.
      Since:
      3.0.0
    • getCurrentMaxVisibleColumns

      public int getCurrentMaxVisibleColumns()
      Returns the maximum visible number of columns of the currently selected sheet.
      Returns:
      Since:
      3.8.1
    • getCurrentMaxVisibleRows

      public int getCurrentMaxVisibleRows()
      Returns the maximum visible number of rows of the currently selected sheet.
      Returns:
      Since:
      3.8.1
    • setMaxVisibleColumns

      public void setMaxVisibleColumns(int maxcols)
      Sets the maximum visible number of columns of this spreadsheet. For example, if you set this parameter to 40, it will allow showing only column 0 to column 39. the minimal value of max number of columns must large than 0. Since 3.8.1, if you set maximum visible number of columns to 0, it means you allow end user to adjust the visible number of columns.
      Default : 0. (since 3.8.1)
      Parameters:
      maxcols - the maximum visible number of columns
      Since:
      3.0.0
    • setMaxVisibleRows

      public void setMaxVisibleRows(int maxrows)
      Sets the maximum visible number of rows of this spreadsheet. For example, if you set this parameter to 40, it will allow showing only row 0 to 39. The minimal value of max number of rows must large than 0. Since 3.8.1, if you set maximum visible number of rows to 0, it means you allow end user to adjust the visible number of rows.
      Default : 0. (since 3.8.1)
      Parameters:
      maxrows - the maximum visible number of rows
      Since:
      3.0.0
    • getImporter

      public Importer getImporter()
      Gets the importer that import the file in the specified src ( getSrc()) to Book data model. The default importer is excel importer.
      Returns:
      the importer
    • setImporter

      public void setImporter(Importer importer)
      Parameters:
      importer - the importer to import a spreadsheet file from a document format (e.g. an Excel file) by setSrc(String). The default importer is io.keikai.importer.XlsxImporter
    • clearClientCache

      public void clearClientCache(SSheet sheet)
      Call this method to clear client side cache for a Sheet and fine tune data loading speed. Note if the given sheet is the currently selected sheet, it will be ignored.
      Parameters:
      sheet - the sheet
      Since:
      3.7.0
    • getUndoableActionManager

      public UndoableActionManager getUndoableActionManager()
    • isKeepCellSelection

      public boolean isKeepCellSelection()
      Returns true if keep the cell selection box when lost focus; default to false.
      Returns:
      true if keep the cell selection box when lost focus; default to false.
      Since:
      3.8.1
    • setKeepCellSelection

      public void setKeepCellSelection(boolean keep)
      Sets true to keep the cell selection box when lost focus.
      Parameters:
      keep - true to keep the cell selection box when lost focus.
      Since:
      3.8.1
    • getSheetMaxVisibleRows

      public int getSheetMaxVisibleRows(SSheet sheet)
      Returns the max visible rows of the specified sheet
      Parameters:
      sheet -
      Since:
      3.8.1
    • getSheetMaxVisibleColumns

      public int getSheetMaxVisibleColumns(SSheet sheet)
      Returns the max visible columns of the specified sheet
      Parameters:
      sheet -
      Since:
      3.8.1
    • setSheetMaxVisibleRows

      public void setSheetMaxVisibleRows(SSheet sheet, int maxRows)
      Sets the max visible rows of the specified sheet
      Parameters:
      sheet -
      Since:
      3.8.1
    • setSheetMaxVisibleColumns

      public void setSheetMaxVisibleColumns(SSheet sheet, int maxColumns)
      Sets the max visibles columns of the specified sheet.
      Parameters:
      sheet -
      Since:
      3.8.1
    • setShowAddRow

      public void setShowAddRow(boolean showAddRow)
      Sets whether show the add row button in sheetbar.
      Parameters:
      showAddRow - true if want to show add row button in sheetbar
      Since:
      3.8.1
    • isShowAddRow

      public boolean isShowAddRow()
      Returns whether show the add row button in sheetbar.
      Since:
      3.8.1
    • setShowAddColumn

      public void setShowAddColumn(boolean showAddColumn)
      Sets whether show the add column button in sheetbar.
      Parameters:
      showAddColumn - true if want to show add column button in sheetbar
      Since:
      3.8.1
    • isShowAddColumn

      public boolean isShowAddColumn()
      Returns whether show the add column button in sheetbar.
      Since:
      3.8.1
    • parseLinkAddress

      public static Object[] parseLinkAddress(Book book, String linkAddress)
    • notifyLoadedAreaChange

      public void notifyLoadedAreaChange()
      NotifyChange the currently loaded area and freeze area if exists.
      Since:
      3.8.3
    • notifyVisibleAreaChange

      public void notifyVisibleAreaChange()
      NotifyChange the currently visible area and freeze area if exists.
      Since:
      3.8.3
    • setIgnoreAutoHeight

      public void setIgnoreAutoHeight(boolean b)
      Whether ignore row's autoHeight calculation. Default to false. Calculating text height and doing row's autoHeight adjustment is an expensive operation. In application, if your cell height is fixed then you can set this flag to true to avoid Keikai Spreadsheet to calculate this information and thus speed up your application a bit. However, if you need Keikai Spreadsheet to calculate row's autoHeight, you have to keep it at false. Though not encouraged, note that whenever you set it from true to false, Spreadsheet will invalidate itself to gurantee the autocalculation works.
      Parameters:
      b -
      Since:
      3.8.3
    • getClipboard

      public UserActionContext.Clipboard getClipboard()
      Return current Server Clipboard
      Returns:
      current Server Clipboard; null if no copy source.
      Since:
      5.7.0
    • clearClipboard

      public void clearClipboard()
      Clear current Server Clipboard
      Since:
      5.7.0
    • setClipboard

      public void setClipboard(UserActionContext.Clipboard clipboard)
      Set current Server Clipboard
      Parameters:
      clipboard -
      Since:
      5.7.0
    • getClientWidgets

      public List<Widget> getClientWidgets()
      Internal used only