Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Mon Apr 07, 2025 2:59 pm

Is there a way to read/identify where the data is located behind the chart?

For example, if there a way to find out where the following are located:
- series container (red): i.e. =Sheet1!$d$3:$f$3
- category container (purple): i.e. =Sheet1!$b$6:$b$9
- data container (blue): i.e. =Sheet1!$d$6:$f$9

datarange coordinates.png

beyeb38077
 
Posts: 14
Joined: Mon Apr 07, 2025 2:45 pm

Tue Apr 08, 2025 8:30 am

Hello,

Thanks for your inquiry.
Sorry, Spire.Presentation does not support reading the cell range of the data in the chart. Could you tell us the purpose of getting the cell range? So that we can provide better help. Thanks in advance.

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Thu Apr 17, 2025 10:40 am

I want to update this existing chart. I don't want to create a new version. I have to work with this specific chart. However, there is a lot of data behind this chart that I cannot remove and I don't know where the series, categories and data are located behind the chart and I'm not allowed to move these components.

Heres my template:
mychart.zip


I want to send this data dynamically to those components:

series = ["Jan-25"]
categories = ["cocacola","pepsi","monster","fanta"]
data = [25%,12%,30%,45%]

During my search I found that I can dynamically find the series using `chart.Series[0].NamedRange` but it doesnt help me find the other components.

before:
inputchart.png



after:
outputchart.png

beyeb38077
 
Posts: 14
Joined: Mon Apr 07, 2025 2:45 pm

Fri Apr 18, 2025 10:37 am

Hello,

Thanks for your reply.
Please try the following code to verify whether it meets your needs.
Code: Select all
 IChart Chart = ppt.Slides[0].Shapes[0] as IChart;
 int CategoriesCount = Chart.Categories.Count;
 for(int i = 0; i < CategoriesCount; i++)
 {
     CellRange dataRange = Chart.Categories[i].DataRange;
     string dataRangeText = dataRange.Text;
     Console.WriteLine($"[{i}] '{dataRangeText}' (Col:{dataRange.Column}, Row:{dataRange.Row})");
 }

 int SeriesCount = Chart.Series.Count;
 for (int i = 0;i < SeriesCount;i++)
 {
     CellRanges values = Chart.Series[i].Values;

     for (int j = 0; j < values.Count; j++)
     {
         Console.WriteLine($"Series[{i}] Val='{values[j].Text}' (Col:{values[j].Column}, Row:{values[j].Row})");
     }
     
 }
 CellRanges seriesLabel = Chart.Series.SeriesLabel;
 int count = seriesLabel.Count;
 for (int i = 0; i < count; i++)
 {
   
     Console.WriteLine($"'{seriesLabel[i].Text}' (Column:{seriesLabel[i].Column}, Row:{seriesLabel[i].Row})");
 }

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 757
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Presentation