Agregue controles ActiveX usando Aspose.Cells
Contents
[
Hide
]
Puede agregar controles ActiveX con Aspose.Cells usando elShapeCollection.addActiveXControl() método. Este método toma un parámetroTipo de controlque indica qué tipo de control ActiveX debe agregarse dentro de una hoja de trabajo. Tiene los siguientes valores.
- CAJA
- CAJA COMBO
- BOTÓN DE COMANDO
- IMAGEN
- ETIQUETA
- CUADRO DE LISTA
- BOTON DE RADIO
- BARRA DE DESPLAZAMIENTO
- GIRAR_BOTÓN
- CAJA DE TEXTO
- BOTÓN DE ACTIVACIÓN
- DESCONOCIDO
Una vez que haya agregado el control ActiveX dentro de la colección de formas, puede acceder al objeto de control ActiveX a través deForma.ActiveXControl propiedad y luego establecer sus diversas propiedades.
Agregue el control ActiveX del botón de alternar usando Aspose.Cells
El siguiente código de ejemplo agrega el control ActiveX del botón de alternar usando Aspose.Cells. Descargue elarchivo de salida de Excel generado con este código para su referencia.
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); |