チャートを SVG 形式の画像に変換する
Contents
[
Hide
]
Scalable Vector Graphics (SVG) は、対話機能とアニメーションもサポートする 2 次元グラフィックス用の XML ベースのベクター画像形式です。 SVG 仕様は、1999 年に World Wide Web Consortium (W3C) によって開発されたオープン スタンダードです。
SVG 画像とその動作は XML テキスト ファイルで定義されます。これは、それらを検索、索引付け、スクリプト化、および圧縮できることを意味します。 XML ファイルとして、SVG 画像は任意のテキスト エディターで作成および編集できますが、描画ソフトウェアで作成されることが多いです。
Aspose.Cells は、BMP、JPEG、PNG、GIF、SVG などのさまざまな形式でグラフを画像に保存できます。この記事では、グラフを SVG 形式で保存する方法について説明します。
次のサンプル コードは、Aspose.Cells を使用してグラフを SVG 形式の画像に変換する方法を説明しています。このコードは、ソース Microsoft の Excel ファイルを読み込み、最初のワークシートで見つかった最初のグラフを SVG に保存します。
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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object from source file | |
Workbook workbook = new Workbook(dataDir + "SampleChartBook.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access first chart inside the worksheet | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[0]; | |
// Set image or print options | |
Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
opts.ImageType = ImageType.Svg; | |
// Save the chart to svg format | |
chart.ToImage(dataDir + "Image_out.svg", opts); |