Aggiungi controlli ActiveX utilizzando Aspose.Cells
Contents
[
Hide
]
È possibile aggiungere controlli ActiveX con Aspose.Cells utilizzando il fileShapeCollection.addActiveXControl() metodo. Questo metodo accetta un parametroTipo di controlloche indica quale tipo di controllo ActiveX deve essere aggiunto all’interno di un foglio di lavoro. Ha i seguenti valori.
- CHECK_BOX
- CASELLA COMBINATA
- PULSANTE DI COMANDO
- IMMAGINE
- ETICHETTA
- LISTA_BOX
- PULSANTE_RADIO
- BARRA DI SCORRIMENTO
- SPIN_BUTTON
- CASELLA DI TESTO
- INTERRUTTORE
- SCONOSCIUTO
Dopo aver aggiunto il controllo ActiveX all’interno della raccolta delle forme, è possibile accedere all’oggetto del controllo ActiveX tramiteShape.ActiveXControl property e quindi impostarne le varie proprietà.
Aggiungi il controllo ActiveX del pulsante di commutazione utilizzando Aspose.Cells
Il seguente codice di esempio aggiunge Toggle Button ActiveX Control utilizzando Aspose.Cells. Scaricare il filefile excel di output generato con questo codice come riferimento.
This file contains hidden or 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.getDataDir(AddActiveXControl.class); | |
// Create workbook object | |
Workbook wb = new Workbook(); | |
// Access first worksheet | |
Worksheet sheet = wb.getWorksheets().get(0); | |
// Add Toggle Button ActiveX Control inside the Shape Collection | |
Shape s = sheet.getShapes().addActiveXControl(ControlType.TOGGLE_BUTTON, 4, 0, 4, 0, 100, 30); | |
// Access the ActiveX control object and set its linked cell property | |
ActiveXControl c = s.getActiveXControl(); | |
c.setLinkedCell("A1"); | |
// Save the worbook in xlsx format | |
wb.save(dataDir + "output.xlsx", SaveFormat.XLSX); |