非原始の形のデータ
Contents
[
Hide
]
非原始の形のデータへのアクセス
時々、ビルトインでない形状からデータにアクセスする必要があります。ビルトインの形状は原始形状と呼ばれ、そうでないものは非原始形状と呼ばれます。例えば、異なる曲線接続線を使用して独自の形状を定義することができます。
非原始の形状
Aspose.Cellsでは、非原始の形状にはタイプAutoShapeType.NotPrimitiveが割り当てられます。Shape.AutoShapeTypeプロパティを使用してそのタイプを確認できます。
Shape.Pathsプロパティを使用して形状データにアクセスします。これにより、非原始の形状を構成するすべての接続パスが返されます。これらのパスは、各セグメント内のポイントを含むセグメントのリストを保持するShapePathタイプです。
非原始の形状の例を示す |
---|
![]() |
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 | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
Workbook workbook = new Workbook(dataDir + "NonPrimitiveShape.xlsx"); | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Accessing the user defined shape | |
Shape shape = worksheet.Shapes[0]; | |
if (shape.AutoShapeType == AutoShapeType.NotPrimitive) | |
{ | |
// Access shape's data | |
ShapePathCollection shapePathCollection = shape.Paths; | |
// Access information of indvidual path | |
foreach (ShapePath shapePath in shapePathCollection) | |
{ | |
// Access path segment list | |
ShapeSegmentPathCollection pathSegments = shapePath.PathSegementList; | |
// Access individual path segment | |
foreach (ShapeSegmentPath pathSegment in pathSegments) | |
{ | |
// Gets the points in path segment | |
ShapePathPointCollection segmentPoints = pathSegment.Points; | |
foreach (ShapePathPoint pathPoint in segmentPoints) | |
{ | |
Console.WriteLine("X: " + pathPoint.X + ", Y: " + pathPoint.Y); | |
} | |
} | |
} | |
} |