|
| 1 | +--- |
| 2 | +title: Hide Toolbar, Formula Bar, or Sheet Bar in Spreadsheet |
| 3 | +description: Learn how to hide the toolbar, formula bar, and sheet bar in the Blazor Spreadsheet component. |
| 4 | +type: how-to |
| 5 | +page_title: How to Change the Visibility of Spreadsheet Parts in Blazor |
| 6 | +slug: spreadsheet-kb-hide-toolbar-formula-sheet-bar |
| 7 | +tags: spreadsheet, blazor, toolbar, formula bar, sheet bar, customization, css, visibility |
| 8 | +res_type: kb |
| 9 | +ticketid: 1676073 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +<table> |
| 15 | + <tbody> |
| 16 | + <tr> |
| 17 | + <td>Product</td> |
| 18 | + <td>Spreadsheet for Blazor</td> |
| 19 | + </tr> |
| 20 | + </tbody> |
| 21 | +</table> |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +I want to display only the spreadsheet portion and hide the toolbar, formula bar, and sheet bars in the Spreadsheet component. |
| 26 | + |
| 27 | +## Solution |
| 28 | + |
| 29 | +To change the visibility of the toolbar, formula bar, and sheet bar in the Spreadsheet for Blazor, apply conditional CSS classes to hide the respective components. |
| 30 | + |
| 31 | +````RAZOR |
| 32 | +<style> |
| 33 | + .hide-header .k-spreadsheet-header { |
| 34 | + display: none; |
| 35 | + } |
| 36 | +
|
| 37 | + .hide-action-bar .k-spreadsheet-action-bar { |
| 38 | + display: none; |
| 39 | + } |
| 40 | +
|
| 41 | + .hide-sheets-bar .k-spreadsheet-sheets-bar { |
| 42 | + display: none; |
| 43 | + } |
| 44 | +</style> |
| 45 | +
|
| 46 | +<TelerikCheckBox Id="showHeader" @bind-Value="@ShowHeader" /> |
| 47 | +<label for="showHeader">Show Header</label> |
| 48 | +<TelerikCheckBox Id="showActionBar" @bind-Value="@ShowActionBar" /> |
| 49 | +<label for="showActionBar">Show Action Bar</label> |
| 50 | +<TelerikCheckBox Id="showSheetsBar" @bind-Value="@ShowSheetsBar" /> |
| 51 | +<label for="showSheetsBar">Show Sheets Bar</label> |
| 52 | +
|
| 53 | +<TelerikSpreadsheet Data="@SpreadsheetData" |
| 54 | + Class="@SpreadsheetClass"> |
| 55 | +</TelerikSpreadsheet> |
| 56 | +
|
| 57 | +@code { |
| 58 | + private byte[]? SpreadsheetData { get; set; } |
| 59 | + private bool ShowHeader { get; set; } |
| 60 | + private bool ShowActionBar { get; set; } |
| 61 | + private bool ShowSheetsBar { get; set; } |
| 62 | +
|
| 63 | + // Dynamically generate the class based on the checkbox states |
| 64 | + private string SpreadsheetClass => $"{(ShowHeader ? "" : "hide-header")} " + |
| 65 | + $"{(ShowActionBar ? "" : "hide-action-bar")} " + |
| 66 | + $"{(ShowSheetsBar ? "" : "hide-sheets-bar")}"; |
| 67 | +
|
| 68 | + protected override async Task OnInitializedAsync() |
| 69 | + { |
| 70 | + SpreadsheetData = Convert.FromBase64String(SampleExcelFile); |
| 71 | +
|
| 72 | + // Or, load a file from your file system. |
| 73 | + // Specify the full File namespace or use namespace aliases |
| 74 | + // to avoid ambiguous reference with the Telerik SVG icon File. |
| 75 | + // FileData = System.IO.File.ReadAllBytes("C:\\Documents\\MyWorkbook.xlsx"); |
| 76 | +
|
| 77 | + await base.OnInitializedAsync(); |
| 78 | + } |
| 79 | +```` |
| 80 | + |
| 81 | +## See Also |
| 82 | + |
| 83 | +- [Spreadsheet Overview](https://docs.telerik.com/blazor-ui/components/spreadsheet/overview) |
0 commit comments