أضف عناصر تحكم ActiveX باستخدام Aspose.Cells
Contents
[
Hide
]
يمكنك إضافة عناصر تحكم ActiveX باستخدام Aspose.Cells باستخدام ملفShapeCollection.AddActiveXControl () طريقة. هذه الطريقة تأخذ معلمةنوع التحكمالذي يوضح نوع عنصر تحكم ActiveX الذي يجب إضافته داخل ورقة العمل. لديها القيم التالية.
- نوع التحكم
- نوع التحكم
- ControlType.CommandButton
- نوع التحكم
- نوع التحكم
- نوع التحكم
- نوع التحكم. زر راديو
- نوع التحكم. شريط التمرير
- نوع التحكم
- ControlType.TextBox
- نوع التحكم
- نوع التحكم. غير معروف
بمجرد إضافة عنصر تحكم ActiveX داخل مجموعة الأشكال ، يمكنك بعد ذلك الوصول إلى كائن عنصر تحكم ActiveX عبرالشكل ثم قم بتعيين خصائصها المختلفة.
يضيف نموذج التعليمات البرمجية التالي عنصر تحكم ActiveX للزر تبديل باستخدام Aspose.Cells.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object | |
Workbook wb = new Workbook(); | |
// Access first worksheet | |
Worksheet sheet = wb.Worksheets[0]; | |
// Add Toggle Button ActiveX Control inside the Shape Collection | |
Shape s = sheet.Shapes.AddActiveXControl(ControlType.ToggleButton, 4, 0, 4, 0, 100, 30); | |
// Access the ActiveX control object and set its linked cell property | |
ActiveXControl c = s.ActiveXControl; | |
c.LinkedCell = "A1"; | |
// Save the worbook in xlsx format | |
wb.Save(dataDir + "AddActiveXControls_out.xlsx", SaveFormat.Xlsx); |