Daten in nicht primitiver Form
Zugriff auf Daten nicht-primitiver Form
Manchmal müssen Sie auf Daten aus einer Form zugreifen, die nicht eingebaut ist. Eingebaute Formen werden primitive Formen genannt; solche, die es nicht sind, werden nicht-primitive genannt. Sie können beispielsweise eigene Formen mit verschiedenen verbundenen Kurvenlinien definieren.
Eine nicht-primitive Form
In Aspose.Cells werden nicht-primitive Formen mit dem Typ AutoShapeType.NotPrimitive versehen. Sie können ihren Typ mithilfe der Eigenschaft Shape.AutoShapeType überprüfen.
Greifen Sie auf die Formdaten mithilfe der Eigenschaft Shape.Paths zu. Es gibt alle verbundenen Pfade zurück, die die nicht-primitive Form bilden. Diese Pfade sind vom Typ ShapePath, der eine Liste aller Segmente enthält, die wiederum die Punkte in jedem Segment enthalten.
Zeigt ein Beispiel für eine nicht-primitive Form |
---|
![]() |
// 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); | |
} | |
} | |
} | |
} |