Interface ITabSheet
Represents worksheet and chartsheet tab in Excel.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface ITabSheet : IParentApplication
Properties
Charts
Gets a charts collection in the sheet. Read-only.
Declaration
IChartShapes Charts { get; }
Property Value
Type | Description |
---|---|
IChartShapes |
CheckBoxes
Gets the ICheckBoxes collection with all ICheckBoxShape inside the sheet. Read-only.
Declaration
ICheckBoxes CheckBoxes { get; }
Property Value
Type | Description |
---|---|
ICheckBoxes |
Examples
The following code illustrates how to access ICheckBoxes collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add combobox
worksheet.CheckBoxes.AddCheckBox(1, 1, 20, 100);
worksheet.CheckBoxes.AddCheckBox(5, 5, 20, 100);
//Check count
Console.Write(worksheet.CheckBoxes.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
CodeName
Gets the name used by macros to access workbook items. Read-only.
Declaration
string CodeName { get; }
Property Value
Type | Description |
---|---|
System.String |
ComboBoxes
Gets the IComboBoxes collection with all IComboBoxShape inside the sheet. Read-only.
Declaration
IComboBoxes ComboBoxes { get; }
Property Value
Type | Description |
---|---|
IComboBoxes |
Examples
The following code illustrates how to access the IComboBoxes collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add combobox
IComboBoxShape combobox1 = worksheet.ComboBoxes.AddComboBox(1, 1, 20, 100);
IComboBoxShape combobox2 = worksheet.ComboBoxes.AddComboBox(5, 5, 20, 100);
//Get count
Console.Write(worksheet.ComboBoxes.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
IsPasswordProtected
Gets a Boolean value indicating whether sheet is protected with a password. Read-only.
Declaration
bool IsPasswordProtected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsRightToLeft
Gets or sets a Boolean value indicating whether sheet is displayed right to left.
Declaration
bool IsRightToLeft { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsSelected
Gets a Boolean value indicating whether tab of the sheet is selected. Read-only.
Declaration
bool IsSelected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Name
Gets or sets the name of the sheet.
Declaration
string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String |
OptionButtons
Gets the IOptionButtons collection with all IOptionButtonShape inside the sheet. Read-only.
Declaration
IOptionButtons OptionButtons { get; }
Property Value
Type | Description |
---|---|
IOptionButtons |
Examples
The following code illustrates how to access the IOptionButtons collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add option button
worksheet.OptionButtons.AddOptionButton(1, 1, 20, 100);
worksheet.OptionButtons.AddOptionButton(5, 5, 20, 100);
//Get count
Console.Write(worksheet.OptionButtons.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
Pictures
Gets the IPictures collection in the sheet. Read-only.
Declaration
IPictures Pictures { get; }
Property Value
Type | Description |
---|---|
IPictures |
Examples
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add picture
worksheet.Pictures.AddPicture("Image.png");
//Get picture
IPictureShape picture = worksheet.Pictures[0];
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
ProtectContents
Gets a Boolean value indicating whether content in the sheet is protected. Read-only.
Declaration
bool ProtectContents { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
ProtectDrawingObjects
Gets a Boolean value indicating whether drawing objects in the sheet is protected. Read-only.
Declaration
bool ProtectDrawingObjects { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Protection
Gets protected options. Read-only. For sets protection options use "Protect" method.
Declaration
ExcelSheetProtection Protection { get; }
Property Value
Type | Description |
---|---|
ExcelSheetProtection |
ProtectScenarios
Gets a Boolean value indicating whether scenarios in the sheet is protected. Read-only.
Declaration
bool ProtectScenarios { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Shapes
Gets the IShapes collection in the sheet. Read-only.
Declaration
IShapes Shapes { get; }
Property Value
Type | Description |
---|---|
IShapes |
Examples
The following code illustrates how to access the IShapes collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add shapes
worksheet.Shapes.AddAutoShapes(AutoShapeType.Rectangle, 2, 2, 40, 100);
worksheet.Shapes.AddAutoShapes(AutoShapeType.Rectangle, 5, 5, 40, 100);
//Check count
Console.Write(worksheet.Shapes.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
TabColor
Gets or sets the tab color of the sheet.
Declaration
ExcelKnownColors TabColor { get; set; }
Property Value
Type | Description |
---|---|
ExcelKnownColors |
TabColorRGB
Gets or sets the tab color RGB of the sheet.
Declaration
Color TabColorRGB { get; set; }
Property Value
Type | Description |
---|---|
System.Drawing.Color |
TabIndex
Gets the index number of the sheet within the tabsheets collection. Read-only.
Declaration
int TabIndex { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
TextBoxes
Gets a ITextBoxes collection with all ITextBoxShape inside the sheet. Read-only.
Declaration
ITextBoxes TextBoxes { get; }
Property Value
Type | Description |
---|---|
ITextBoxes |
Examples
The following code illustrates how to access ITextBoxes collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add textbox
ITextBoxShape textbox1 = worksheet.TextBoxes.AddTextBox(1, 1, 20, 100);
ITextBoxShape textbox2 = worksheet.TextBoxes.AddTextBox(5, 5, 20, 100);
//Set name
textbox1.Name = "TextBox1";
textbox2.Name = "TextBox2";
//Get count
Console.Write(worksheet.TextBoxes.Count);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//2
Visibility
Gets or sets the control visibility of sheet to end user.
Declaration
WorksheetVisibility Visibility { get; set; }
Property Value
Type | Description |
---|---|
WorksheetVisibility |
Workbook
Gets the parent workbook of the sheet. Read-only.
Declaration
IWorkbook Workbook { get; }
Property Value
Type | Description |
---|---|
IWorkbook |
Zoom
Gets or sets the value that represents zoom factor of document. Value must be in range from 10 till 400.
Declaration
int Zoom { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Activate()
Activates the sheet which is equivalent to clicking the sheet's tab.
Declaration
void Activate()
Examples
Following code illustrates how to activate a sheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(2);
ITabSheet sheet = workbook.Worksheets[1];
// Activates the sheet
sheet.Activate();
workbook.SaveAs("Activate.xlsx");
workbook.Close();
excelEngine.Dispose();
Protect(String)
Protects a sheet with specified password so that it cannot be modified.
Declaration
void Protect(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | Represents a password to protect with. |
Examples
Following code illustrates how to protect the sheet
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
ITabSheet sheet = workbook.Worksheets[0];
// Protect the sheet
sheet.Protect("Syncfusion");
workbook.SaveAs("Protect.xlsx");
workbook.Close();
excelEngine.Dispose();
Protect(String, ExcelSheetProtection)
Protects a sheet with specified password and ExcelSheetProtection so that it cannot be modified.
Declaration
void Protect(string password, ExcelSheetProtection options)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | Represents a password to protect. |
ExcelSheetProtection | options | Represents sheet protection option. |
Examples
Following code illustrates how to protect the sheet with Excel sheet protection option.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
ITabSheet sheet = workbook.Worksheets[0];
// Protect the sheet
sheet.Protect("Syncfusion");
workbook.SaveAs("Protect.xlsx");
workbook.Close();
excelEngine.Dispose();
Select()
Selects the tab sheet.
Declaration
void Select()
Examples
Following code illustrates how to select the sheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(2);
ITabSheet sheet = workbook.Worksheets[1];
// Selects the sheet
sheet.Select();
workbook.SaveAs("Select.xlsx");
workbook.Close();
excelEngine.Dispose();
Unprotect(String)
Removes protection from a sheet. This method has no effect if the sheet or workbook isn't protected.
Declaration
void Unprotect(string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | password | Password to unprotect. |
Examples
Following code illustrates how to remove the protection from the sheet.
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
ITabSheet sheet = workbook.Worksheets[0];
// Unprotect the sheet
sheet.Unprotect("Syncfusion");
workbook.SaveAs("UnProtect.xlsx");
workbook.Close();
excelEngine.Dispose();
Unselect()
Removes the selection from the sheet.
Declaration
void Unselect()
Examples
Following code illustrates how to remove the selection from the sheet
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(2);
ITabSheet sheet = workbook.Worksheets[1];
// Removes the selection from the sheet.
sheet.Unselect();
workbook.SaveAs("Unselect.xlsx");
workbook.Close();
excelEngine.Dispose();