チャートシリーズのポイントのXおよびY値のタイプを検索する
Contents
[
Hide
]
可能な使用シナリオ
時々、シリーズ内のチャートポイントのXおよびY値のタイプを知りたいことがあります。Aspose.Cellsでは、この目的のためにChartPoint.XValueTypeおよびChartPoint.YValueTypeプロパティを提供しています。これらのプロパティを効果的に使用するには、Chart.Calculate()メソッドを呼び出す必要があります。
チャートシリーズのX値とY値のタイプを検索する
次のサンプルコードは、サンプルExcelファイルを読み込み、最初のワークシート内の最初のチャートにアクセスします。その後、Chart.Calculate()メソッドを呼び出し、最初のチャートポイントのXおよびY値のタイプを検索し、それらをコンソールに出力します。参考のために、以下に示すコンソール出力をご覧ください。
サンプルコード
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 | |
//Load sample Excel file containing chart. | |
Workbook wb = new Workbook(sourceDir + "sampleFindTypeOfXandYValuesOfPointsInChartSeries.xlsx"); | |
//Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
//Access first chart. | |
Chart ch = ws.Charts[0]; | |
//Calculate chart data. | |
ch.Calculate(); | |
//Access first chart point in the first series. | |
ChartPoint pnt = ch.NSeries[0].Points[0]; | |
//Print the types of X and Y values of chart point. | |
Console.WriteLine("X Value Type: " + pnt.XValueType); | |
Console.WriteLine("Y Value Type: " + pnt.YValueType); |
コンソール出力
X Value Type: IsString
Y Value Type: IsNumeric