查找图表系列中点的X和Y值类型
Contents
[
Hide
]
可能的使用场景
有时,您希望了解系列中图表点的X和Y值的类型。Aspose.Cells提供了ChartPoint.XValueType和 ChartPoint.YValueType属性,可用于此目的。请注意,在有效使用这些属性之前,您必须调用Chart.Calculate()方法。
查找图表系列中点的X和Y值类型
以下示例代码加载示例Excel文件并访问第一个工作表中的第一个图表。然后调用Chart.Calculate()方法,并找到第一个图表点的X和Y值的类型,并将它们打印到控制台。请参阅下面显示的控制台输出进行参考。
示例代码
This file contains hidden or 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