Invia la forma avanti o indietro all interno del foglio di lavoro
Possibili Scenari di Utilizzo
Quando sono presenti più forme nello stesso punto, la visibilità è determinata dalle posizioni dell’ordine Z. Aspose.Cells fornisce il metodo Shape.ToFrontOrBack() che cambia la posizione dell’ordine Z della forma. Se vuoi inviare la forma in secondo piano, userai un numero negativo come -1, -2, -3, ecc. e se vuoi inviare la forma in primo piano, userai un numero positivo come 1, 2, 3, ecc.
Invia la forma avanti o indietro all’interno del foglio di lavoro
Il seguente codice di esempio spiega l’uso del metodo Shape.ToFrontOrBack(). Si prega di vedere il file Excel di esempio utilizzato all’interno del codice e il file Excel di output generato da esso. La schermata mostra l’effetto del codice sul file Excel di esempio in esecuzione.
Codice di Esempio
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
//Load source Excel file | |
Workbook wb = new Workbook(srcDir + "sampleToFrontOrBack.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.getWorksheets().get(0); | |
//Access first and fourth shape | |
Shape sh1 = ws.getShapes().get(0); | |
Shape sh4 = ws.getShapes().get(3); | |
//Print the Z-Order position of the shape | |
System.out.println("Z-Order Shape 1: " + sh1.getZOrderPosition()); | |
//Send this shape to front | |
sh1.toFrontOrBack(2); | |
//Print the Z-Order position of the shape | |
System.out.println("Z-Order Shape 4: " + sh4.getZOrderPosition()); | |
//Send this shape to back | |
sh4.toFrontOrBack(-2); | |
//Save the output Excel file | |
wb.save(outDir + "outputToFrontOrBack.xlsx"); |