SVG形式でチャートを画像に変換

Contents
[ ]

次のサンプルコードは、Aspose.Cellsを使用してチャートをSVG形式の画像に変換する方法を説明しています。コードでは、ソースのExcelファイルをロードし、その後、最初のワークシートで見つかった最初のチャートをSVG形式で保存します。

次のスクリーンショットは、サンプルコードで作成されたSVG形式の変換されたチャート画像を示しています。

出力画像

todo:image_alt_text

SVGはXMLベースの形式であるため、このスクリーンショットに示すように、出力チャート画像をNotepadなどのテキストエディタで開くこともできます。

テキストエディタでSCGを出力

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);