チャートを SVG 形式の画像に変換する

Contents
[ ]

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

次のスクリーンショットは、サンプル コードで作成された SVG 形式の変換されたグラフ イメージを示しています。

出力画像

todo:画像_代替_文章

SVG は XML ベースの形式であるため、このスクリーンショットに示すように、メモ帳などのテキスト エディターで出力グラフ イメージを開くこともできます。

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

todo:画像_代替_文章

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