I am trying to read data from the charts.
Below is the part of my code that I implemented.
SeriesCollection series = chart.getNSeries();
String categoryData = series.getCategoryData();
System.out.println(categoryData);
Iterator it = series.iterator();
while(it.hasNext()){
Series s = it.next();
String values = s.getValues();
System.out.println(values );
}
output -
=‘Dist1 - L&T Capital’!$B$5:$B$7
=‘Dist1 - L&T Capital’!$C$5:$C$7
I tried above code to read values and category data but what I am getting is the source sheet range instead of the actual values that are displayed on the charts.
How can I get the actual values from charts? Is there any way?
@Amjad_Sahi @johnson.shi
Can you please help me with this.
@vbAspose,
Once you get the category and series (values) range, you have to use your own code to to get data. For example, you may easily traverse through that range (loop through the range) and get your desired (actual) values of the chart’s source.
@Amjad_Sahi
For example, you may easily traverse through that range (loop through the range) and get your desired (actual) values of the chart’s source.
yes, I am doing the same way and it works for column and bar type charts but when I fetch from pie or doughnut charts I need the values in percentage.
- So do I need to calculate the percentage value myself from the range that I am getting.
- And how can I get the unit of value like $,% etc.
- How can I get the sheet name from =‘Dist1 - L&T Capital’!$C$5:$C$7 the range.
right now I am using substring() to get sheet name. Is there any other way that aspose provides to fetch sheet name directly.
@vbAspose,
1). You have to evaluate it by yourselves.
2). You may evaluate accordingly:
e.g.
Sample code:
...
SeriesCollection nseries = chart.getNSeries();
//check the first data series data labels and data point
boolean check = nseries.get(0).getDataLabels().getShowPercentage();
String numformat = nseries.get(0).getDataLabels().getNumberFormat();
String text = nseries.get(0).getPoints().get(0).getDataLabels().getText();
3). You are doing right.