[]
        
(Showing Draft Content)

Tab Strip

SpreadJS provides plenty of options to control the behavior of the tab strip and its elements. You can perform various operations such as changing the sheet name, setting sheet color, arranging sheets, setting the position and width of tab strip, etc. by using the properties of the Workbook.options field.

SpreadJS workbook tab strip UI showing sheet tabs and related UI elements developers configure through Workbook options.

Change Sheet Name

You can change the name of a sheet from the tab strip in either of the following ways:

  • Double-click a sheet tab to start editing the sheet name.

  • Right-click a sheet tab and select Rename from the context menu.

    After the sheet name enters edit mode, enter the new name and press Enter or click outside the tab to apply the change. Press Esc to cancel editing.

SpreadJS sheet tab rename workflow showing a worksheet tab entering edit mode and applying a new sheet name.

You can enable or disable the ability to edit sheet names using options.tabEditable property. The default value of this property is true.

spread.options.tabEditable = false; // false: disable, true: enable

When options.tabEditable is set to false, users cannot start sheet name editing by double-clicking the sheet tab or by using the Rename context menu command.

The Rename command is also available from the sheet tab context menu in the SpreadJS Designer Component.

Arrange Sheet Tabs

You can arrange sheet names in the tab strip by selecting the sheet tab and dragging it between any two sheets. An indicator is displayed while dragging the sheet, as shown in the below image. Release the mouse to move the sheet.

SpreadJS tab strip showing a worksheet tab drag indicator for reordering sheets with the allowSheetReorder option.

You can enable the ability to re-order the sheet tabs by setting the options.allowSheetReorder property to true.

spread.options.allowSheetReorder = true; // true: enable, false: disable

The SheetMoving and SheetMoved events occur before and after the sheet is dragged and moved respectively. To cancel the movement of the sheet, you can set the cancel parameter of SheetMoving class to true.

Set Sheet Tab Style

You can set the sheet tab styles, such as text style, background color, and icons, based on the states of the sheet tab. To set styles for sheet tabs, you can use the sheetTabStyles or defaultSheetTabStyles property of the Workbook class.

The sheetTabStyles property applies a specific state style for each sheet tab, whereas the defaultSheetTabStyles property sets the default state style of all sheet tabs.

Refer to the following image that sets the background color, fore color, and icon for different states of sheet tabs.

SpreadJS sheet tabs showing customized state styles with different background colors, foreground colors, and icons for developers.

The following code sample implements styles for the sheet tabs in different states.

// Set a new style for the normal state of 'Sheet1'.
spread.sheetTabStyles.add(GC.Spread.Sheets.SheetTabState.normal, {
    icons: [{ src: '../images/img.png', width: 20, height: 20 }],
    foreColor: 'red',
    font: 'bolder',
    backColor: 'green',
}, ['Sheet1']);

// Set a default style for the protected state of all sheet tabs.
spread.options.defaultSheetTabStyles = {
    [GC.Spread.Sheets.SheetTabState.protected]: {
        icons: [{ src: '../images/lock.jpg', width: 20, height: 20 }],
        foreColor: 'blue',
        backColor: 'orange',
    }
};

SpreadJS Designer also provides support for customizing sheet tab styles through the SETTINGS tab.

To manage sheet tab styles:

  1. Click the General button in the Sheet Settings group.

  2. Select the SheetTab tab to define the color and styles for a specific sheet tab state.

    SpreadJS Designer SETTINGS tab showing the SheetTab settings area for configuring sheet tab state style properties.

  3. Click the Manage Style button to configure the tab state styles.

  4. Choose the state where you want to make changes from the Tab State Style List and then click the Edit icon for that state.

    SpreadJS Designer sheet tab Manage Style interface showing the Tab State Style List and edit command for states.

  5. In the Tab Style Setting dialog, apply the desired font styles, background color, and icon for the selected state.

    SpreadJS Designer Tab Style Setting dialog showing font, background color, and icon properties for a selected tab state.

  6. Click OK.

    The changes will apply to the sheet tab.

To manage the default sheet tab styles:

  1. Select the TabStrip button in the Spread Settings group.

    This opens the Spread Settings dialog.

    SpreadJS Designer SETTINGS tab showing the TabStrip button used to open Spread Settings for default sheet tab styles.

  2. Select the Manage Style option to set sheet tab state styles.

  3. Select the state from the Tab State Style List and click the Edit icon to make the changes.

  4. Click OK.

    This time, the changes will apply to all sheet tabs.

Support Border Radius for the Appearance of Sheet Tabs

The border appearance of the SheetTab can be customized through the border-radius style of the built-in supported CSS class.

  • Different SheetTab Position have corresponding CSS classes that describe their appearance.

.sjs-tab-strip-bottom-tab{
  border-radius: value;
}

.sjs-tab-strip-left-tab{
  border-radius: value;
}

.sjs-tab-strip-right-tab{
  border-radius: value;
}

.sjs-tab-strip-top-tab{
  border-radius: value;
}
  • The border-radius property under sjs-tab-strip-[position]-tab class only accepts values in pixels. The value must be greater than or equal to 0. If all border-radius values are set to 0, it disables the sheet tab's border radius styling.

  • It supports defining the radius style for each corner individually: top-left, top-right, bottom-left, and bottom-right

SpreadJS SheetTab border radius preview showing corner styling areas developers customize with tab strip CSS classes.

For example:

  1. One value for border-radius indicates that all corners will use this value as the border radius.

.sjs-tab-strip-bottom-tab{
  border-radius: 4px;
}

SpreadJS bottom SheetTab preview showing a uniform CSS border-radius value applied to all tab corners.

  1. Two values for border-radius indicate that the first value denotes the top-left and bottom-right border radius, and the second value denotes the top-right and bottom-left.

.sjs-tab-strip-bottom-tab{
  border-radius: 0px 5px;
}

SpreadJS bottom SheetTab preview showing two CSS border-radius values applied to alternating tab corner pairs.

  1. Three values for border-radius indicate that the first value denotes the top-left border radius, the second value denotes the top-right and bottom-left, and the third value denotes the bottom-right.

.sjs-tab-strip-bottom-tab{
  border-radius: 0px 0px 4px;
}

SpreadJS bottom SheetTab preview showing three CSS border-radius values controlling individual and paired tab corners.

  1. Four values for border-radius indicate the top-left, top-right, bottom-right, and bottom-left border radius.

.sjs-tab-strip-bottom-tab {
    border-radius: 4px 4px 0px 0px;
}

SpreadJS bottom SheetTab preview showing four CSS border-radius values applied separately to each tab corner.

1. The sheet tab border radius style does not support the Excel 2007 theme.

2. Be careful not to make the radius too large for the limitations of the sheet tab width and height.

Display New Tab Button

You can choose to show or hide the New Tab button by using options.newTabVisible property. This button is visible by default.


SpreadJS tab strip showing the New Tab button UI element controlled by the newTabVisible Workbook option.

spread.options.newTabVisible = true; // false: hide, true: show

Display Navigation Buttons

You can specify whether to show the navigation buttons in the workbook by using options.tabNavigationVisible property.


SpreadJS workbook tab strip showing navigation buttons controlled by the tabNavigationVisible option for moving between worksheets.

spread.options.tabNavigationVisible = false; // false: hide, true: show

Display Tab Strip

You can hide the entire tab strip by using options.tabStripVisible property.

SpreadJS workbook showing the tab strip visibility state controlled by the tabStripVisible and tabStripRatio options.

spread.options.tabStripVisible = true; // true: show, false: hide
spread.options.tabStripRatio = 0.5;  // percentage value that specifies the horizontal space allocated to the tab strip

Set Position and Width

You can set the position of the tab strip relative to the workbook using the tabstripPosition workbook option. These positions are supported on touch devices as well as in all SpreadJS themes. The tab strip gets separated from the scrollbar if the position is set to left, right, or top.

Position

Image

Bottom (default)

SpreadJS workbook showing the default bottom tab strip position for worksheet tabs and related navigation UI elements.

Left

SpreadJS workbook showing worksheet tabs positioned on the left side using the tabStripPosition Workbook option.

Right

SpreadJS workbook showing worksheet tabs positioned on the right side using the tabStripPosition Workbook option.

Top

SpreadJS workbook showing worksheet tabs positioned at the top using the tabStripPosition Workbook option.

Note: The resize horizontal bar button is visible only when the position of the tab strip is set to the bottom. The tabStripRatio property is also ignored when the top, left or right position is set.

If the sheet position is set to the left or right and the sheet name is too long to be displayed, it is clipped and indicated by an ellipsis. However, you can change the width of the tab strip to show the complete sheet name by using options.tabStripWidth property. The default and minimum value of this property is 80px.

Note: The options.tabStripWidth property is ignored if the tab strip position is not set to the left or right of the workbook.

SpreadJS side tab strip showing adjusted tabStripWidth so longer worksheet names are displayed instead of clipped.


The following example code sets tab strip position and width.

// Change tab strip position when creating workbook
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {tabStripPosition: GC.Spread.Sheets.TabStripPosition.top});
// Or change tab strip position by workbook options
spread.options.tabStripPosition = GC.Spread.Sheets.TabStripPosition.top;
       
// Change tab strip width when creating workbook
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {tabStripWidth: 200});
// Or change tab strip width by workbook options
spread.options.tabStripWidth = 200;        

The “All Sheets” button

SpreadJS provides an “All Sheets” hamburger button in the tab strip that helps navigate to specific sheet(s) in a workbook more quickly. The button opens a drop-down list consisting of the available sheet(s).


The “All Sheets” button automatically appears when all the sheets cannot be displayed completely in the tab strip. It can also be displayed by resizing the bar to hide sheets.


SpreadJS tab strip All Sheets hamburger button opening a worksheet list for faster navigation when tabs overflow.

You can choose whether to display the hamburger button by setting the allSheetsListVisible option using the AllSheetsListVisibility

enumeration values such as “hide”, “show”, and “auto” (default).

// Automatically show or hide the "All Sheets" button - Default
function AutoButton(spread) {
    spread.options.allSheetsListVisible = GC.Spread.Sheets.AllSheetsListVisibility.auto;
}

// Always show the "All Sheets" button
function ShowButton(spread) {
    spread.options.allSheetsListVisible = GC.Spread.Sheets.AllSheetsListVisibility.show;
}

// Hide the "All Sheets" button
function HideButton(spread) {
    spread.options.allSheetsListVisible = GC.Spread.Sheets.AllSheetsListVisibility.hide;
}

Note: The position of the “All Sheets” hamburger button is retained irrespective of the set value in the allSheetsListVisible option.

The below table depicts different scenarios associated with the “All Sheets” hamburger button.

Scenario

Example

The “All Sheets” dialog highlights the active sheet and the hovered sheet.

SpreadJS All Sheets dialog showing active worksheet highlighting and hover state feedback in the sheet list UI element.

The “All Sheets” button changes color on the hover.

SpreadJS All Sheets hamburger button showing hover color feedback in the tab strip navigation UI element.

The “All sheets” dialog highlights all the selected active sheets.

SpreadJS All Sheets dialog showing multiple selected active worksheets highlighted in the sheet navigation list.

The tab strip will display the selected sheet from the “All Sheets” dialog if it is not in the currently displayed area.

SpreadJS All Sheets dialog selecting a worksheet outside the visible tab strip area and displaying its sheet tab.

The “All Sheets” dialog does not show hidden sheets.

For example, Sheet4, Sheet6, and Sheet7 are hidden sheets in the example image.

SpreadJS All Sheets dialog listing visible worksheets only while hidden sheets are excluded from the navigation UI.

The “All Sheets” dialog shows only matched sheets and automatically selects the first matched sheet in the list when user start typing in the search box. (Matching is case-insensitive.)

SpreadJS All Sheets dialog search box filtering worksheet names and automatically selecting the first case-insensitive match.

The “All Sheets” dialog matches the active sheet when the input value is empty.

SpreadJS All Sheets dialog showing the active worksheet matched and selected when the search input is empty.

If the workbook is too short to fully display the "All Sheets" dialog, the dialog will automatically hide the search box.

SpreadJS All Sheets dialog adapting to a short workbook height by hiding the search box UI element.

Notes:

The search feature also supports keyboard operation.

  • Up & Down Arrow: Move selection up or down.

  • Enter: Set the selected worksheet as the active one.

  • ESC: Close the “All Sheets” dialog.

Using SpreadJS Designer

You can also set the tab strip options using SpreadJS Designer by accessing the TabStrip settings in the SETTINGS ribbon tab as shown below:

SpreadJS Designer SETTINGS ribbon tab showing the TabStrip settings entry for configuring workbook tab strip options.

SpreadJS Designer TabStrip settings dialog showing workbook options for configuring tab strip visibility, position, and behavior.