تحويل الرسم البياني إلى صورة بتنسيق SVG

Contents
[ ]

الكود العيني التالي يشرح كيفية استخدام Aspose.Cells لتحويل رسم بياني إلى صورة بتنسيق SVG. يقوم الكود بتحميل ملف Excel المصدر ثم يحفظ الرسم البياني الأول الموجود في الورقة العمل الأولى لـ SVG.

تُظهر اللقطة الشاشة التالية الرسم البياني المحول إلى صورة بتنسيق SVG الذي تم إنشاؤه باستخدام الكود العيني.

صورة الناتج

todo:image_alt_text

نظرًا لأن SVG هو تنسيق مبني على XML، يمكنك أيضًا فتح صورة الرسم البياني الناتجة في محرر نصوص مثل Notepad كما هو موضح في لقطة الشاشة هذه.

صورة الناتج SVG في محرر نصوص

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ConvertCharttoImageinSVGFormat.class);
// Create workbook object from source Excel file
Workbook workbook = new Workbook(dataDir + "sample.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Access the first chart inside the worksheet
Chart chart = worksheet.getCharts().get(0);
// Save the chart into image in SVG format
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageType(ImageType.SVG);
chart.toImage(dataDir + "ChartImage.svg", options);