Activación de hojas y activación de un Cell en la hoja de trabajo

Activando Hojas y Activando un Cell

Aspose.Cells proporciona llamadas API específicas para activar una hoja y una celda. Por ejemplo, elWorksheetCollection.ActiveSheetIndexLa propiedad es útil para configurar la hoja activa en un libro de trabajo. Del mismo modo, elHoja de trabajo.ActiveCellLa propiedad se puede usar para establecer y obtener una celda activa en la hoja de cálculo.

Para asegurarse de que las barras de desplazamiento horizontal o vertical estén en la posición del índice de fila y columna en la que desea mostrar datos específicos, use elHoja de trabajo.FirstVisibleRowyWorksheet.FirstVisibleColumnpropiedades.

El siguiente ejemplo muestra cómo activar una hoja de trabajo y hacer una celda activa en ella. El siguiente resultado se genera al ejecutar el código. Las barras de desplazamiento se desplazan para hacer que la segunda fila y la segunda columna sean sus primeras filas y columnas visibles.

Configuración de la celda B2 como una celda activa

todo:imagen_alternativa_texto

Java código para configurar una hoja de trabajo activa en Excel

// 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(ActivatingSheetsandActivatingCell.class);
// Instantiate a new Workbook
Workbook workbook = new Workbook();
// Get the first worksheet in the workbook
Worksheet worksheet = workbook.getWorksheets().get(0);
// Get the cells in the worksheet
Cells cells = worksheet.getCells();
// Input data into B2 cell
cells.get(1, 1).putValue("Hello World!");
// Set the first sheet as an active sheet
workbook.getWorksheets().setActiveSheetIndex(0);
// Set B2 cell as an active cell in the worksheet
worksheet.setActiveCell("B2");
// Set the B column as the first visible column in the worksheet
worksheet.setFirstVisibleColumn(1);
// Set the 2nd row as the first visible row in the worksheet
worksheet.setFirstVisibleRow(1);
// Save the excel file
workbook.save(dataDir + "activecell.xls");