Datos en forma no primitiva
Acceso a datos de forma no primitiva
A veces, necesitas acceder a datos de una forma que no está incorporada. Las formas incorporadas se llaman formas primitivas; las que no lo son se llaman no primitivas. Por ejemplo, puedes definir tus propias formas usando diferentes líneas conectadas curvas.
Una forma no primitiva
En Aspose.Cells para Python via .NET, las formas no primitivas se asignan al tipo AutoShapeType.NOT_PRIMITIVE. Puedes verificar su tipo utilizando la propiedad Shape.auto_shape_type.
Acceda a los datos de la forma utilizando la propiedad Shape.paths. Devuelve todos los caminos conectados que componen la forma no primitiva. Estos caminos son del tipo ShapePath que contiene una lista de todos los segmentos que a su vez contienen los puntos en cada segmento.
Muestra un ejemplo de una forma no primitiva |
---|
![]() |
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)) |