using(Presentation pres = new Presentation(filePathToPPT))
{
ISlide slide = pres.Slides[0];
IShape ch = FindShapeByName(slide, "chartPlaceholderName"); //finds the chart on the slide
IChart chart = (IChart)ch;
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
int s = chart.ChartData.Series.Count;
s = chart.ChartData.Categories.Count;
int seriesCount = 1, elementCount = 1;
List<string> seriesNames = new List<string>();
List<string> yValues = new List<string>();
seriesNames.Add("N1");
yValue.Add("35");
seriesNames.Add("N2");
yValue.Add("60");
for(int i=0; i<seriesNames.Count; i++)
{
chart.ChartDataSeries.Add(fact.GetCell(index, 0, seriesCounter, seriesNames[i], chart.Type);
seriesCount++;
}
for (int j = 0; j < seriesCounter - 1; j++)
{
IChartSeries series = chart.ChartData.Series[j];
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(index, 0, j + 1, 100)); //Set to default 100
series.Labels.DefaultDataLabelFormat.ShowValue = true;
series.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = true;
series.Labels.Text = yValue[j]; //This is what I want to do
}
pres.Save(saveFileAs, SaveFormat.Pptx);
}
That is what I want the code to do but I’m not aware of anyway to assign my own value to a label that isnt the datavalue.
Many thanks.