ワークシート内でShape FrontまたはBackを送信する
Contents
[
Hide
]
可能な使用シナリオ
同じ位置に複数の図形が存在する場合、それらがどのように表示されるかは、z-オーダー位置で決定されます。Aspose.Cellsは、図形のz-オーダー位置を変更するShape.ToFrontOrBack()メソッドを提供します。形を後方に送りたい場合は、-1、-2、-3などの負の数を使用し、形を前方に送りたい場合は、1、2、3などの正の数を使用します。
ワークシート内でShape FrontまたはBackを送信する
次のサンプルコードは、Shape.ToFrontOrBack()メソッドの使用方法を説明しています。コード内で使用されるsample Excel fileとそれによって生成されるoutput Excel fileをご覧ください。スクリーンショットは、コードのサンプルExcelファイルへの効果を示しています。
サンプルコード
This file contains 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 | |
//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"); |