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 für Python via .NET werden nicht-primitive Formen vom Typ AutoShapeType.NOT_PRIMITIVE zugewiesen. Ihre Art kann mit der Eigenschaft Shape.auto_shape_type überprüft werden.
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 |
---|
![]() |
from aspose.cells import Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
workbook = Workbook(dataDir + "NonPrimitiveShape.xlsx") | |
worksheet = workbook.worksheets[0] | |
# Accessing the user defined shape | |
shape = worksheet.shapes[0] | |
if shape.auto_shape_type == AutoShapeType.NOT_PRIMITIVE: | |
# Access shape's data | |
shapePathCollection = shape.paths | |
# Access information of indvidual path | |
for shapePath in shapePathCollection: | |
# Access path segment list | |
pathSegments = shapePath.path_segement_list | |
# Access individual path segment | |
for pathSegment in pathSegments: | |
# Gets the points in path segment | |
segmentPoints = pathSegment.points | |
for pathPoint in segmentPoints: | |
print("X: " + str(pathPoint.x) + ", Y: " + str(pathPoint.y)) |