ActiveX ComboBox Kontrolünü Güncelle
Olası Kullanım Senaryoları
Aspose.Cells for Python via .NET kullanarak ActiveX ComboBox Kontrolünün değerlerini okuyabilir veya yazabilirsiniz. Lütfen ActiveX Kontrolüne Shape.active_x_control özelliği üzerinden erişin ve türünü ActiveXControl.type özelliğiyle kontrol edin, bu ControlType.COMBO_BOX değerini döndürmelidir ve ardından ComboBoxActiveXControl nesnesine tip dönüştürün ve çeşitli özelliklerini okuyun veya değiştirin.
Lütfen aşağıdaki örnek kodda kullanılan örnek excel dosyasını indirin.
ActiveX ComboBox Kontrolünü Güncelleme
Aşağıdaki ekran görüntüsü, örnek excel dosyası üzerinde örnek kodun etkisini göstermektedir. Görebileceğiniz gibi, AktifX ComboBox değeri “Bu bir combo box kontrolüdür” olarak güncellenmiştir.
![]() |
---|
Örnek Kod
örnek excel dosyası içinde bulunan AktifX ComboBox Kontrolünün değerini güncelleyen aşağıdaki örnek kodu takip edin.
from aspose import pycore | |
from aspose.cells import Workbook | |
from aspose.cells.drawing.activexcontrols import ComboBoxActiveXControl, ControlType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create a workbook | |
wb = Workbook(dataDir + "SourceFile.xlsx") | |
# Access first shape from first worksheet | |
shape = wb.worksheets[0].shapes[0] | |
# Access ActiveX ComboBox Control and update its value | |
if shape.active_x_control != None: | |
# Access Shape ActiveX Control | |
c = shape.active_x_control | |
# Check if ActiveX Control is ComboBox Control | |
if c.type == ControlType.COMBO_BOX: | |
# Type cast ActiveXControl into ComboBoxActiveXControl and change its value | |
comboBoxActiveX = pycore.cast(ComboBoxActiveXControl, c) | |
comboBoxActiveX.value = "This is combo box control with updated value." | |
# Save the workbook | |
wb.save(dataDir + "OutputFile_out.xlsx") |