Datos en forma no primitiva
Contents
[
Hide
]
Acceso a datos de forma no primitiva
A veces, necesita acceder a los datos desde una forma que no está integrada. Las formas integradas se denominan formas primitivas; los que no lo son se llaman no primitivos. Por ejemplo, puede definir sus propias formas usando diferentes líneas conectadas con curvas.
Una forma no primitiva
En Aspose.Cells, a las formas no primitivas se les asigna el tipoAutoShapeType.NotPrimitive . Puede verificar su tipo usando elForma.AutoShapeTypepropiedad.
Acceda a los datos de la forma usando elShape.Pathspropiedad. Devuelve todos los caminos conectados que comprenden la forma no primitiva. Estos caminos son del tiporuta de formaque 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. |
---|
![]() |
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); | |
} | |
} | |
} | |
} |