البيانات في شكل غير بدائي
Contents
[
Hide
]
الوصول إلى البيانات ذات الشكل غير البدائي
في بعض الأحيان ، تحتاج إلى الوصول إلى البيانات من شكل غير مضمن. تسمى الأشكال المضمنة الأشكال البدائية ؛ تلك التي لا تسمى غير بدائية. على سبيل المثال ، يمكنك تحديد الأشكال الخاصة بك باستخدام خطوط مختلفة متصلة منحنى.
شكل غير بدائي
في Aspose.Cells ، يتم تخصيص النوع للأشكال غير البدائيةنوع تلقائي . يمكنك التحقق من نوعها باستخدام ملفShape.getAutoShapeType ()طريقة.
قم بالوصول إلى بيانات الشكل باستخدام ملفShape.getPaths ()طريقة. تقوم بإرجاع جميع المسارات المتصلة التي تشكل الشكل غير البدائي. هذه المسارات من النوع ShapePath الذي يحتوي على قائمة بجميع المقاطع التي بدورها تحتوي على النقاط في كل مقطع.
يوضح مقتطف الشفرة التالي استخدامShape.getPaths ()طريقة للوصول إلى معلومات المسار ذات الشكل غير البدائي.
يعرض مثالاً لشكل غير بدائي
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-Java | |
// The path to the resource directory | |
String dataDir = Utils.getSharedDataDir(NonPrimitiveShape.class) + "DrawingObjects/"; | |
Workbook workbook = new Workbook(dataDir + "NonPrimitiveShape.xlsx"); | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Accessing the user defined shape | |
Shape shape = worksheet.getShapes().get(0); | |
if (shape.getAutoShapeType() == AutoShapeType.NOT_PRIMITIVE) { | |
// Access Shape paths | |
ShapePathCollection shapePathCollection = shape.getPaths(); | |
// Access information of individual shape path | |
ShapePath shapePath = shapePathCollection.get(0); | |
// Access shape segment path list | |
ShapeSegmentPathCollection shapeSegmentPathCollection = shapePath.getPathSegementList(); | |
// Access individual segment path | |
ShapeSegmentPath shapeSegmentPath = shapeSegmentPathCollection.get(0); | |
ShapePathPointCollection segmentPoints = shapeSegmentPath.getPoints(); | |
for (Object obj : segmentPoints) { | |
ShapePathPoint pathPoint = (ShapePathPoint) obj; | |
System.out.println("X: " + pathPoint.getX() + ", Y: " + pathPoint.getY()); | |
} | |
} |