ワークシート内の形状を前面または背面に送信
Contents
[
Hide
]
考えられる使用シナリオ
同じ場所に複数の形状が存在する場合、それらがどのように表示されるかは、Z オーダーの位置によって決まります。 Aspose.Cells提供Shape.ToFrontOrBack()形状のZオーダー位置を変更するメソッド。形状を背面に送りたい場合は、-1、-2、-3 などの負の数を使用します。形状を前面に送りたい場合は、1、2、3、などの正の数を使用します。等
ワークシート内の形状を前面または背面に送信
次のサンプル コードは、Shape.ToFrontOrBack()方法。をご覧くださいサンプル Excel ファイルコード内で使用され、出力エクセルファイルそれによって生成されます。スクリーンショットは、実行時のサンプル 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-.NET | |
//Load source Excel file | |
Workbook wb = new Workbook(sourceDir + "sampleToFrontOrBack.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access first and fourth shape | |
Shape sh1 = ws.Shapes[0]; | |
Shape sh4 = ws.Shapes[3]; | |
//Print the Z-Order position of the shape | |
Console.WriteLine("Z-Order Shape 1: " + sh1.ZOrderPosition); | |
//Send this shape to front | |
sh1.ToFrontOrBack(2); | |
//Print the Z-Order position of the shape | |
Console.WriteLine("Z-Order Shape 4: " + sh4.ZOrderPosition); | |
//Send this shape to back | |
sh4.ToFrontOrBack(-2); | |
//Save the output Excel file | |
wb.Save(outputDir + "outputToFrontOrBack.xlsx"); |