Articles in this section
Category / Section

How to remove the add new sheet Icon from Angular Spreadsheet sheet Tabs?

This article explains how to remove the ‘Add New Sheet’ icon from Angular Spreadsheet sheet tabs. This can be achieved by setting display: none for the ‘Add Sheet’ icon using the cssClass property. Additionally, you can remove the ‘Insert’ option in the footer context menu using the removeContextMenuItems method in the contextMenuBeforeOpen event.

[app.component.html]

<ejs-spreadsheet #default="" (created)="created()" cssclass="e-custom" (contextmenubeforeopen)="contextMenuBeforeOpen($event)">
 <e-sheets>
   <e-sheet name="Car Sales Report">
     <e-ranges>
       <e-range [datasource]="data"></e-range>
     </e-ranges>

     <e-columns>
       <e-column [width]="180"></e-column>
       <e-column [width]="130"></e-column>
       <e-column [width]="130"></e-column>
       <e-column [width]="180"></e-column>
       <e-column [width]="130"></e-column>
       <e-column [width]="120"></e-column>
     </e-columns>
   </e-sheet>
 </e-sheets>
</ejs-spreadsheet> 

[app.component.ts]

import { Component, ViewEncapsulation, Inject, ViewChild } from '@angular/core';
import { getDefaultData } from './data';
import { SpreadsheetComponent } from '@syncfusion/ej2-angular-spreadsheet';
import { closest } from '@syncfusion/ej2-base';
import { BeforeOpenCloseMenuEventArgs } from '@syncfusion/ej2-navigations';

@Component({
 selector: 'app-root',
 templateUrl: 'app.component.html',
 styleUrls: ['app.component.css'],
 encapsulation: ViewEncapsulation.None,
})
export class AppComponent {
 constructor() {}
 @ViewChild('default')
 public spreadsheetObj: SpreadsheetComponent;
 public data: Object[] = getDefaultData();

 created() {
   this.spreadsheetObj.cellFormat(
     { fontWeight: 'bold', textAlign: 'center', verticalAlign: 'middle' },
     'A1:F1'
   );
 }
 contextMenuBeforeOpen(args: BeforeOpenCloseMenuEventArgs) {
   // Condition for footer context menu.
   if (closest((args.event as any).target, '.e-toolbar-item')) {
     // To remove the insert option in the footer context menu.
     this.spreadsheetObj.removeContextMenuItems(['Insert']);
   }
 }
}

[app.component.css]

/* Hide the add sheet icon using CSS. */
.e-custom .e-add-sheet-tab {
 display: none;
}

Refer to the working sample for additional details and implementation: Sample

Output:

output.png

API Reference:

https://ej2.syncfusion.com/angular/documentation/api/spreadsheet/#cssclass
https://ej2.syncfusion.com/angular/documentation/api/spreadsheet/#removecontextmenuitems
https://helpej2.syncfusion.com/angular/documentation/api/spreadsheet/#contextmenubeforeopen

Documentation Link:
https://ej2.syncfusion.com/angular/documentation/spreadsheet/worksheet
https://ej2.syncfusion.com/angular/documentation/spreadsheet/context-menu

Conclusion

We hope you enjoyed learning on how to remove the add new sheet Icon from Angular Spreadsheet sheet Tabs.

You can refer to our Angular Spreadsheet feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Angular Spreadsheet Example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Access denied
Access denied