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