チャートのレンダリング
Contents
[
Hide
]
チャートのレンダリング
Aspose.Cells API は、Excel チャートを画像や PDF 形式に変換することをサポートしており、追加のツールやアプリケーションは必要ありません。レンダリングのサポートを提供するために、チャートクラスが暴露したイメージへ & PDFへアプリケーションの要件に最も適したオーバーロードの真実性を持つメソッド。
グラフを画像にレンダリングする
のChart.ToImage & PDFへメソッドには、単純なレンダリングだけでなく高度なレンダリングもサポートするための多数のオーバーロードがあります。アプリケーション要件がグラフをデフォルトの寸法でレンダリングすることである場合は、Chart.ToImage方法は以下の通り。
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); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Workbook | |
int sheetIndex = workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection | |
Worksheet worksheet = workbook.Worksheets[sheetIndex]; | |
// Adding sample values to cells | |
worksheet.Cells["A1"].PutValue(50); | |
worksheet.Cells["A2"].PutValue(100); | |
worksheet.Cells["A3"].PutValue(150); | |
worksheet.Cells["B1"].PutValue(4); | |
worksheet.Cells["B2"].PutValue(20); | |
worksheet.Cells["B3"].PutValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5); | |
// Accessing the instance of the newly added chart | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex]; | |
// Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart.NSeries.Add("A1:B3", true); | |
// Converting chart to image | |
chart.ToImage(dataDir + "chartEMF_out.emf", ImageType.Emf); | |
// Converting chart to Bitmap | |
System.Drawing.Bitmap bitmap = chart.ToImage(); | |
bitmap.Save(dataDir + "chartBMP_out.bmp", System.Drawing.Imaging.ImageFormat.Bmp); |
詳細設定を使用して、グラフを画像にレンダリングすることもできます。 Aspose.Cells API がオーバーロード バージョンを公開しましたChart.ToImageのインスタンスを受け入れることができるメソッドImageOrPrintOptions、解像度、スムージング モード、画像形式などのパラメータを指定できるようにします。
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); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Workbook | |
int sheetIndex = workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection | |
Worksheet worksheet = workbook.Worksheets[sheetIndex]; | |
// Adding sample values to cells | |
worksheet.Cells["A1"].PutValue(50); | |
worksheet.Cells["A2"].PutValue(100); | |
worksheet.Cells["A3"].PutValue(150); | |
worksheet.Cells["B1"].PutValue(4); | |
worksheet.Cells["B2"].PutValue(20); | |
worksheet.Cells["B3"].PutValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5); | |
// Accessing the instance of the newly added chart | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex]; | |
// Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart.NSeries.Add("A1:B3", true); | |
// Create an instance of ImageOrPrintOptions and set a few properties | |
ImageOrPrintOptions options = new ImageOrPrintOptions() | |
{ | |
VerticalResolution = 300, | |
HorizontalResolution = 300, | |
SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias | |
}; | |
// Convert chart to image with additional settings | |
chart.ToImage(dataDir + "chartPNG_out.png", options); |
PDF へのレンダリング チャート
グラフを PDF 形式でレンダリングするために、Aspose.Cells API はChart.ToPdf結果の PDF をディスク パスまたはストリームに格納する機能を備えたメソッド。
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); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Adding a new worksheet to the Workbook | |
int sheetIndex = workbook.Worksheets.Add(); | |
// Obtaining the reference of the newly added worksheet by passing its index to WorksheetCollection | |
Worksheet worksheet = workbook.Worksheets[sheetIndex]; | |
// Adding sample values to cells | |
worksheet.Cells["A1"].PutValue(50); | |
worksheet.Cells["A2"].PutValue(100); | |
worksheet.Cells["A3"].PutValue(150); | |
worksheet.Cells["B1"].PutValue(4); | |
worksheet.Cells["B2"].PutValue(20); | |
worksheet.Cells["B3"].PutValue(50); | |
// Adding a chart to the worksheet | |
int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column, 5, 0, 15, 5); | |
// Accessing the instance of the newly added chart | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex]; | |
// Adding Series Collection (chart data source) to the chart ranging from "A1" cell to "B3" | |
chart.NSeries.Add("A1:B3", true); | |
// Converting chart to PDF | |
chart.ToPdf(dataDir + "chartPDF_out.pdf"); |
レンダリングでサポートされているグラフの種類
現在、レンダリングがサポートされていないチャート タイプがいくつかあります。このようなチャート タイプには、次のものが含まれます。** N** の**下表の**列をサポート。
グラフの種類 | チャートのサブタイプ | 対応 |
---|---|---|
桁 | 桁 | はい |
積み上げ列 | はい | |
Column100PercentStacked | はい | |
列 3DClustered | はい | |
Column3D積み上げ | はい | |
Column3D100PercentStacked | はい | |
列 3D | はい | |
バー | バー | はい |
棒積み上げ | はい | |
Bar100Percent積み上げ | はい | |
Bar3DClustered | はい | |
Bar3D積み上げ | はい | |
Bar3D100PercentStacked | はい | |
ライン | ライン | はい |
LineStacked | はい | |
Line100PercentStacked | はい | |
LineWithDataMarkers | はい | |
LineStackedWithDataMarkers | はい | |
Line100PercentStackedWithDataMarkers | はい | |
Line3D | はい | |
パイ | パイ | はい |
Pie3D | はい | |
パイパイ | はい | |
パイ爆発 | はい | |
Pie3DExploded | はい | |
パイバー | はい | |
散布 | 散布 | はい |
ScatterConnectedByCurvesWithDataMarker | はい | |
ScatterConnectedByCurvesWithoutDataMarker | はい | |
ScatterConnectedByLinesWithDataMarker | はい | |
ScatterConnectedByLinesWithoutDataMarker | はい | |
範囲 | 範囲 | はい |
エリア積み上げ | はい | |
Area100PercentStacked | はい | |
エリア3D | はい | |
Area3D積み上げ | はい | |
Area3D100PercentStacked | はい | |
ドーナツ | ドーナツ | はい |
ドーナツ爆発 | はい | |
レーダー | レーダー | はい |
RadarWithDataMarkers | はい | |
レーダーいっぱい | はい | |
水面 | Surface3D | N |
SurfaceWireframe3D | N | |
表面輪郭 | N | |
SurfaceContourWireframe | N | |
バブル | バブル | はい |
バブル3D | N | |
ストック | 株価高低終値 | はい |
株式オープン高低クローズ | はい | |
在庫高低終値 | はい | |
在庫量OpenHighLowClose | はい | |
シリンダー | シリンダー | はい |
円柱積み上げ | はい | |
円柱 100%積み上げ | はい | |
円柱棒 | はい | |
円柱棒積み上げ | はい | |
CylindricalBar100PercentStacked | はい | |
円筒柱 3D | はい | |
円錐 | 円錐 | はい |
円錐積み上げ | はい | |
円錐 100% 積み上げ | はい | |
円錐バー | はい | |
円錐棒積み上げ | はい | |
ConicalBar100PercentStacked | はい | |
ConicalColumn3D | はい | |
ピラミッド | ピラミッド | はい |
ピラミッド積み上げ | はい | |
Pyramid100PercentStacked | はい | |
ピラミッドバー | はい | |
ピラミッド棒積み上げ | はい | |
PyramidBar100PercentStacked | はい | |
PyramidColumn3D | はい | |
箱ひげ | 箱ひげ | よ |
漏斗 | 漏斗 | はい |
パレートライン | パレートライン | はい |
サンバースト | サンバースト | はい |
ツリーマップ | ツリーマップ | はい |
滝 | 滝 | はい |
ヒストグラム | ヒストグラム | よ |
地図 | 地図 | な |
サポートされていないチャート タイプを画像または PDF にレンダリングしようとすると、サイズが 0 の画像または空白の PDF になる可能性があります。