Aktivera ark och aktivera en Cell i kalkylblad

Aktivera ark och aktivera en Cell

Aspose.Cells tillhandahåller specifika API-anrop för att aktivera ett ark och en cell. Till exempelWorksheetCollection.ActiveSheetIndexegenskapen är användbar för att ställa in det aktiva bladet i en arbetsbok. På samma sättArbetsblad.ActiveCellegenskap kan användas för att ställa in och få en aktiv cell i kalkylbladet.

AnvändWorksheet.FirstVisibleRowochWorksheet.FirstVisibleColumnegenskaper.

Följande exempel visar hur man aktiverar ett kalkylblad och gör en aktiv cell i det. Följande utdata genereras när koden exekveras. Rullningslisterna rullas för att göra den andra raden och den andra kolumnen som deras första synliga rad och kolumn.

Ställer in B2-cell som en aktiv cell

todo:image_alt_text

Java kod för att ställa in ett aktivt kalkylblad i 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");