ActiveXControlBase.Workbook
ActiveXControlBase.Workbook property
Gets the Workbook object.
public Workbook Workbook { get; }
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Drawing;
using Aspose.Cells.Drawing.ActiveXControls;
using System;
public class ActiveXControlBasePropertyWorkbookDemo
{
public static void Run()
{
// Create a new workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
try
{
// Add an ActiveX control to the worksheet
Shape shape = worksheet.Shapes.AddActiveXControl(ControlType.CheckBox, 1, 0, 1, 0, 100, 30);
CheckBoxActiveXControl checkBox = (CheckBoxActiveXControl)shape.ActiveXControl;
// Set some properties to make the example meaningful
checkBox.Caption = "Sample CheckBox";
checkBox.IsAutoSize = true;
// Demonstrate the Workbook property (read-only)
Workbook controlWorkbook = checkBox.Workbook;
Console.WriteLine("ActiveX Control Workbook reference obtained successfully.");
Console.WriteLine("Workbook has " + controlWorkbook.Worksheets.Count + " worksheets.");
// Verify the workbook reference is the same as our original workbook
if (controlWorkbook == workbook)
{
Console.WriteLine("The ActiveX control's Workbook property correctly references the parent workbook.");
}
// Save the workbook
workbook.Save("ActiveXControlWorkbookDemo.xlsx");
Console.WriteLine("Workbook saved successfully.");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}
}
}
}
See Also
- class Workbook
- class ActiveXControlBase
- namespace Aspose.Cells.Drawing.ActiveXControls
- assembly Aspose.Cells