非プリミティブ形状のデータ
Contents
[
Hide
]
非プリミティブ形状のデータへのアクセス
組み込みではない図形からデータにアクセスする必要がある場合があります。組み込みシェイプはプリミティブ シェイプと呼ばれます。そうでないものは、非プリミティブと呼ばれます。たとえば、さまざまな曲線を接続した線を使用して、独自の形状を定義できます。
非原始的な形状
Aspose.Cells では、非プリミティブ シェイプにタイプが割り当てられます。AutoShapeType.NotPrimitive .を使用してそれらのタイプを確認できますShape.AutoShapeType財産。
を使用して形状データにアクセスします。シェイプ.パス財産。非プリミティブ形状を構成するすべての接続されたパスを返します。これらのパスのタイプはシェイプパスこれは、各セグメントのポイントを順番に含むすべてのセグメントのリストを保持します。
非プリミティブ形状の例を示します |
---|
![]() |
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); | |
} | |
} | |
} | |
} |