How to hide worksheet tabs using XlsIO in WinForms?
Syncfusion .NET Excel library supports hiding worksheet tabs by disabling the DisplayWorkbookTabs property available under the IWorkbook interface.
The required worksheet tab can be selected through the DisplayedTab property 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
Conclusion
I hope you enjoyed learning about how to hide worksheet tabs using XlsIO in WinForms.
You can refer to our XlsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.
If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion components.
If you have any queries or require clarification, please let us know in the comments below or contact us through our support forums, Support Tickets, or feedback portal. We are always happy to assist you!