Introduction
If you closely look at the bottom of the Excel file, you will find some tabs. These tabs include:
- Sheet Tabs
- Tabs Scrolling Buttons
Sheet Tabs are the tabs that represent all worksheets in the Excel file. You can click on any desired tab to switch to a particular worksheet. The more worksheets you have, the more sheet tabs will be created. If your Excel file has a good number of worksheets then you would also need some buttons to navigate through all of these sheet tabs. So, Microsoft Excel also provides Tabs Scrolling Buttons that allow to scroll through all sheet tabs as shown below in the figure:
|
Figure: Sheet Tabs & Tabs Scrolling Buttons
|
Using Aspose.Cells , developers can control the visibility of these sheet tabs and tabs scrolling buttons in their Excel files.
Controlling the Visibility of the Tabs
Aspose.Cells provides a class, Workbook that represents an Excel file. Workbook class provides a wide range of properties and methods to manage an Excel file. But, to control the visibility of the tabs in the Excel file, developers may use ShowTabs property of the Workbook class. ShowTabs is a boolean property, which means that it can only store a true or false value.
Hiding Tabs
Developers can hide the tabs of the Excel file by setting the ShowTabs property of the Workbook class to false.
Example:
[C#]
//Hiding the tabs of the Excel file
workbook.ShowTabs = false;
[VB.NET]
'Hiding the tabs of the Excel file
workbook.ShowTabs = False
[JAVA]
//Hiding the tabs of the Excel file
workbook.setSheetTabBarHidden(true);
Making Tabs Visible
Developers can make the tabs (of an Excel file) visible by setting the ShowTabs property of the Workbook class to true.
Example:
[C#]
//Displaying the tabs of the Excel file
workbook.ShowTabs = true;
[VB.NET]
'Displaying the tabs of the Excel file
workbook.ShowTabs = True
[JAVA]
//Displaying the tabs of the Excel file
workbook.setSheetTabBarHidden(false);
Example:
A complete example is given below that opens an Excel file (Book1.xls), makes its tabs hidden and then saves the modified file as output.xls.
[C#]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Creating a file stream containing the Excel file to be opened
FileStream fstream=new FileStream("C:\\book1.xls",FileMode.Open);
//Opening the Excel file through the file stream
workbook.Open(fstream);
//Hiding the tabs of the Excel file
workbook.ShowTabs = false;
//Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("C:\\output.xls",FileFormatType.Default);
//Closing the file stream to free all resources
fstream.Close();
[VB.NET]
'Instantiating a Workbook object
Dim workbook As Workbook = New Workbook()
'Creating a file stream containing the Excel file to be opened
Dim fstream As FileStream = New FileStream("C:\\book1.xls",FileMode.Open)
'Opening the Excel file through the file stream
workbook.Open(fstream)
'Hiding the tabs of the Excel file
workbook.ShowTabs = False
'Saving the modified Excel file in default (that is Excel 2000) format
workbook.Save("C:\\output.xls",FileFormatType.Default)
'Closing the file stream to free all resources
fstream.Close()
[JAVA]
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Opening the Excel file
workbook.open("C:\\book1.xls");
//Hiding the tabs of the Excel file
workbook.setSheetTabBarHidden(true);
//Saving the modified Excel file in default (that is Excel 2000) format
workbook.save("C:\\output.xls");
Excel File - Before Modification
You can see that Book1.xls file contains tabs in the figure below:
|
Figure: Excel file before any modification
|
Excel File - After Executing the Example Code
Book1.xls file is opened by calling the Open method of the Workbook class and then the tabs of the Excel file are made hidden. The modified file is saved as output.xls file whose pictorial view is shown below:
|
Figure: Excel file after modification
|