Category / Section
How to hide worksheet tabs using XlsIO?
1 min read
Syncfusion XlsIO do support hiding worksheet tab by disabling DisplayWorkbookTabs property available under IWorkbook interface.
The required worksheet tab can be selected through DisplayedTab of IWorkbook.
The following complete code snippet explains this.
using (ExcelEngine excelEngine = new ExcelEngine()) { IApplication application = excelEngine.Excel; application.DefaultVersion = ExcelVersion.Excel2016; IWorkbook workbook = application.Workbooks.Create(5); workbook.Worksheets[0].Range["A1:A10"].Text = "Sheet1"; workbook.Worksheets[1].Range["A1:A10"].Text = "Sheet2"; workbook.Worksheets[2].Range["A1:A10"].Text = "Sheet3"; workbook.Worksheets[3].Range["A1:A10"].Text = "Sheet4"; workbook.Worksheets[4].Range["A1:A10"].Text = "Sheet5"; //Hide the tab workbook.DisplayWorkbookTabs = false; //set the display tab workbook.DisplayedTab = 3; workbook.SaveAs("Output.xlsx"); System.Diagnostics.Process.Start("Output.xlsx"); }
A complete working sample can be downloaded from HideTabs.zip.
On executing the above sample, you will get the output as follows.
Output Excel File