ActiveX ComboBox Denetimini Güncelle
Contents
[
Hide
]
Olası Kullanım Senaryoları
ActiveX ComboBox Control’ün değerlerini Aspose.Cells kullanarak okuyabilir veya yazabilirsiniz. Lütfen ActiveX Control’e şu adresten erişin:Shape.ActiveXControl özelliği ve türünü şu yolla kontrol edin:ActiveXControl.Type özellik, geri dönmeliControlType.ComboBox değer ve ardından içine yazınComboBoxActiveXControlnesne ve onun çeşitli özelliklerini okuyun veya değiştirin.
Lütfen indirinörnek excel dosyası Aşağıdaki örnek kodda kullanılan veçıktı excel dosyası onun tarafından oluşturulur.
ActiveX ComboBox Denetimini Güncelle
Aşağıdaki ekran görüntüsü, örnek kodunörnek excel dosyasıGördüğünüz gibi, ActiveX ComboBox değeri “Bu, birleşik giriş kutusu denetimidir” olarak güncellendi.
Basit kod
Aşağıdaki örnek kod, içinde bulunan ActiveX ComboBox Control değerini günceller.örnek excel dosyası.
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-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(UpdateActiveXComboBoxControl.class) + "articles/"; | |
// Create a workbook | |
Workbook wb = new Workbook(dataDir + "sample.xlsx"); | |
// Access first shape from first worksheet | |
Shape shape = wb.getWorksheets().get(0).getShapes().get(0); | |
// Access ActiveX ComboBox Control and update its value | |
if (shape.getActiveXControl() != null) { | |
// Access Shape ActiveX Control | |
ActiveXControl c = shape.getActiveXControl(); | |
// Check if ActiveX Control is ComboBox Control | |
if (c.getType() == ControlType.COMBO_BOX) { | |
// Type cast ActiveXControl into ComboBoxActiveXControl and | |
// change its value | |
ComboBoxActiveXControl comboBoxActiveX = (ComboBoxActiveXControl) c; | |
comboBoxActiveX.setValue("This is combo box control."); | |
} | |
} | |
// Save the workbook | |
wb.save(dataDir + "UpdateActiveXComboBoxControl_out.xlsx"); |