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.

Thu Mar 25, 2021 4:20 pm

Is it possible to add a sting into a given data label?

See image.

I'm only interested to know if this is possible or not, not sample code. Just a yes or no would suffice.

Thanks!

majeed_s
 
Posts: 80
Joined: Thu Mar 25, 2021 4:13 pm

Fri Mar 26, 2021 5:45 am

Hello,

Thanks for your inquiry.
Yes, our Spire.Presentation supports adding new string to a datalabel. Below is the corresponding code for your better reference.
Code: Select all
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("ChartSample2.pptx");
            IChart Chart = ppt.Slides[0].Shapes[0] as IChart;

            ChartDataLabel chartDataLabel = Chart.Series[0].DataLabels.Add();
            chartDataLabel.TextFrame.Text = Chart.Series[0].Values[0].Text;

            TextParagraph tp = chartDataLabel.TextFrame.TextRange.Paragraph;
            TextRange tr = new TextRange(" A");
            tr.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid;
            tr.Format.Fill.SolidColor.Color = Color.Red;
            tr.LatinFont = new TextFont("Times New Roman");
            tp.TextRanges.Append(tr);

            ppt.SaveToFile("result.pptx", FileFormat.Pptx2010);


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Presentation