Ottenere Conteggio Cellule Indirizzo Spostamento Intera Colonna e Intera Riga della Gamma
Possibili Scenari di Utilizzo
Aspose.Cells fornisce l’oggetto Range che ha vari metodi di utilità che facilitano all’utente lavorare facilmente con le gamme di Excel. Questo articolo illustra l’uso dei seguenti metodi o proprietà dell’oggetto Range.
- Indirizzo
Ottiene l’indirizzo della gamma.
- Conteggio celle
Ottiene il conteggio di tutte le celle nella gamma.
- Spostamento
Ottiene la gamma per spostamento.
- Intera Colonna
Restituisce un oggetto Range che rappresenta l’intera colonna (o colonne) che contiene il range specificato.
- Intera Riga
Restituisce un oggetto Range che rappresenta l’intera riga (o righe) che contiene il range specificato.
Ottieni Indirizzo, Conteggio Celle, Spostamento, Intera Colonna e Intera Riga del Range
Il seguente codice di esempio spiega l’uso dei metodi e delle proprietà come discusso in precedenza. Si prega di consultare l’output della console del codice fornito di seguito per un riferimento.
Codice di Esempio
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Create empty workbook. | |
Workbook wb = new Workbook(); | |
// Access first worksheet. | |
Worksheet ws = wb.getWorksheets().get(0); | |
// Create range A1:B3. | |
System.out.println("Creating Range A1:B3\n"); | |
Range rng = ws.getCells().createRange("A1:B3"); | |
// Print range address and cell count. | |
System.out.println("Range Address: " + rng.getAddress()); | |
System.out.println("Cell Count: " + rng.getCellCount()); | |
// Formatting console output. | |
System.out.println("----------------------"); | |
System.out.println(""); | |
// Create range A1. | |
System.out.println("Creating Range A1\n"); | |
rng = ws.getCells().createRange("A1"); | |
// Print range offset, entire column and entire row. | |
System.out.println("Offset: " + rng.getOffset(2, 2).getAddress()); | |
System.out.println("Entire Column: " + rng.getEntireColumn().getAddress()); | |
System.out.println("Entire Row: " + rng.getEntireRow().getAddress()); | |
// Formatting console output. | |
System.out.println("----------------------"); | |
System.out.println(""); |
Output della console
Creating Range A1:B3
Range Address: A1:B3
Cell Count: 6
\----------------------
Creating Range A1
Offset: C3
Entire Column: A:A
Entire Row: 1:1
\----------------------