New Ribbon Tab

This applies to the optional Designer Component Add-On. This demo shows how you how to add a new tab to the ribbon, such as 'Favorites', and how to add custom options to the tab such as frequently used buttons and operations. It also shows how you can hide the other tabs.

This sample shows the following: How to create a "frequently used" button group and place your favorite items in a new ribbon tab. Using search and replace functions instead of font style buttons. You can use the ribbon's config property to edit the tabs and button groups within the tabs to show exactly what you want. Just follow these steps: Clear the ribbon by setting the config.ribbon property to an empty array. Create a new tab object with id, text, and buttonGroups properties. Add the tab to the ribbon. Create a new menu object with label, thumbnailClass, and commandGroup properties. Add that new menu to the ribbon tab you just created Set the existing ribbon config to the one you just created.
let spreadNS = GC.Spread.Sheets; let config = GC.Spread.Sheets.Designer.DefaultConfig; let designer, spread; window.onload = function () { // init initRibbon(); }; function initRibbon() { // clear ribbon config.ribbon = []; // add new ribbon tab let newTab = { id: 'operate', text: 'Favorite', buttonGroups: [], }; config.ribbon.unshift(newTab); // add new menu let basicMenu = { label: 'Frequently used operations', thumbnailClass: 'Frequently used operations', commandGroup: { children: [ { commands: ['formulaAutoSum'], }, { commands: ['insertTable'], }, { type: 'separator', }, { direction: 'vertical', children: [ { commands: ['fontFamily', 'fontSize', 'fontWeight', 'backColor', 'foreColor'], }, { commands: ['find', 'replace', 'setFilter'], }, ], }, { direction: 'vertical', commands: ['showHideVGridLine', 'showHideHGridLine'], }, ], }, }; config.ribbon[0].buttonGroups.unshift(basicMenu); new spreadNS.Designer.Designer(document.getElementById('ribbonHost'), config); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture"/> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-designer/styles/gc.spread.sheets.designer.min.css"> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-shapes/dist/gc.spread.sheets.shapes.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-charts/dist/gc.spread.sheets.charts.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-print/dist/gc.spread.sheets.print.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-barcode/dist/gc.spread.sheets.barcode.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-pdf/dist/gc.spread.sheets.pdf.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-pivot-addon/dist/gc.spread.pivot.pivottables.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-slicers/dist/gc.spread.sheets.slicers.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-formula-panel/dist/gc.spread.sheets.formulapanel.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-io/dist/gc.spread.sheets.io.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-excelio/dist/gc.spread.excelio.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-designer-resources-en/dist/gc.spread.sheets.designer.resource.en.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/spread-sheets-designer/dist/gc.spread.sheets.designer.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/designer/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="container"> <div class="spreadSheet"> <div id="ribbonHost"></div> <div id="ss"></div> </div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .container { height: 100%; } .spreadSheet { height: 100%; } #ribbonHost { height: 100%; } .description { margin: 10px; width: 40%; }