チャートの計算後に軸ラベルを読み取る
Contents
[
Hide
]
考えられる使用シナリオ
を使用して値を計算した後、チャートの軸ラベルを読み取ることができます。Chart.Calculate()方法。をご利用くださいAxis.AxisLabels軸ラベルのリストを返すこの目的のためのプロパティ。
チャートの計算後に軸ラベルを読み取る
をロードする次のサンプル コードを参照してください。サンプル Excel ファイル最初のワークシートのチャートの項目軸ラベルを読み取ります。次に、軸ラベルの値をコンソールに出力します。以下のサンプル コードのコンソール出力を参照してください。
サンプルコード
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 the Excel file containing chart | |
Workbook wb = new Workbook("sampleReadAxisLabelsAfterCalculatingTheChart.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access the chart | |
Chart ch = ws.Charts[0]; | |
//Calculate the chart | |
ch.Calculate(); | |
//Read axis labels of category axis | |
string[] lstLabels = ch.CategoryAxis.GetAxisTexts(); | |
//Print axis labels on console | |
Console.WriteLine("Category Axis Labels: "); | |
Console.WriteLine("---------------------"); | |
//Iterate axis labels and print them one by one | |
for (int i = 0; i < lstLabels.Length; i++) | |
{ | |
Console.WriteLine(lstLabels[i]); | |
} |
コンソール出力
Category Axis Labels:
---------------------
Iran
China
USA
Brazil
England