Dati in Forma Non Primitiva

Accesso ai Dati di Forma Non-Primitiva

A volte, è necessario accedere ai dati da una forma non incorporata. Le forme incorporate sono chiamate forme primitive; quelle che non lo sono vengono chiamate non primitive. Ad esempio, è possibile definire le proprie forme utilizzando diverse linee collegate da curve.

Una Forma Non-Primitiva

In Aspose.Cells, alle forme non primitive viene assegnato il tipo AutoShapeType.NotPrimitive. È possibile controllare il loro tipo utilizzando la proprietà Shape.AutoShapeType.

Accedere ai dati della forma utilizzando la proprietà Shape.Paths. Restituisce tutti i percorsi collegati che compongono la forma non primitiva. Questi percorsi sono del tipo ShapePath che contiene un elenco di tutti i segmenti che a loro volta contengono i punti in ciascun segmento.

Mostra un esempio di una forma non primitiva
todo:image_alt_text
// 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);
}
}
}
}