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.

Wed Oct 27, 2021 9:45 am

Dear Omur,

Please download the new version(Spire.Presentation Pack Hotfix Version:6.10.2) of Spire.Presentation which fixed SPIREPPT-1704 from the below links.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.Pr ... ion/6.10.2

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Sun Oct 31, 2021 12:24 pm

Thank You amy.zhao.
Unfortunately is seems doesn't work.

I'm sharing the source code and output file.

Template File and Result File:
multi.series.test.rar


04-spire.png


Source Code:

Code: Select all
using Spire.Presentation;
using Spire.Presentation.Charts;
using Spire.Presentation.Drawing;
using System;
using System.Collections.Generic;
using System.Linq;

namespace PptxTester
{
    class Program
    {
        static void Main(string[] args)
        {
            //Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("multi.series.test.pptx");


            //Get first slide from template presentation
            var slide = templatePresentation.Slides[0];

            //Get Chart                       
            IChart chart = slide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Chart 5") as IChart;


            chart.ChartData[1, 0].Value = "car 1";
            chart.ChartData[2, 0].Value = "car 2";
            chart.ChartData[3, 0].Value = "car 3";
            chart.ChartData[4, 0].Value = "car 4";
            chart.ChartData[5, 0].Value = "car 5";


            chart.ChartData[0, 1].Value = "brand 1";
            chart.ChartData[0, 2].Value = "brand 2";
            chart.ChartData[0, 3].Value = "brand 3";
            chart.ChartData[0, 4].Value = "brand 4";

            chart.ChartData[1, 1].Value = 50;
            chart.ChartData[2, 1].Value = 60;
            chart.ChartData[3, 1].Value = 40;
            chart.ChartData[4, 1].Value = 60;
            chart.ChartData[5, 1].Value = 50;

            chart.ChartData[1, 2].Value = 55;
            chart.ChartData[2, 2].Value = 45;
            chart.ChartData[3, 2].Value = 35;
            chart.ChartData[4, 2].Value = 25;
            chart.ChartData[5, 2].Value = 14;

            chart.ChartData[1, 3].Value = 20;
            chart.ChartData[2, 3].Value = 30;
            chart.ChartData[3, 3].Value = 40;
            chart.ChartData[4, 3].Value = 10;
            chart.ChartData[5, 3].Value = 20;

            chart.ChartData[1, 4].Value = 20;
            chart.ChartData[2, 4].Value = 20;
            chart.ChartData[3, 4].Value = 20;
            chart.ChartData[4, 4].Value = 20;
            chart.ChartData[5, 4].Value = 20;

            //Set series labels
            chart.Series.SeriesLabel = chart.ChartData["B1", "E1"];

            //Select data               
            chart.Series[0].Values = chart.ChartData["B2", "B6"];
            chart.Series[1].Values = chart.ChartData["C2", "C6"];
            chart.Series[2].Values = chart.ChartData["D2", "D6"];
            chart.Series[3].Values = chart.ChartData["E2", "E6"];

            //Save and launch to view the PPTX document.
            templatePresentation.SaveToFile("multi.series.test.result.case3.fixed.pptx", Spire.Presentation.FileFormat.Pptx2013);
        }
    }
}

omurertanis
 
Posts: 22
Joined: Tue Mar 30, 2021 7:56 pm

Mon Nov 01, 2021 3:55 am

Dear Omur,

Thanks for your feedback.
I found that the new issue you reported is the same as this one (Replace data behind chart but retain visual chart formatting). Kindly note that we have logged this issue in our issue tracking system under the ticket SPIREPPT-1721. Our Dev team is working on it now. Once there is any update, we will keep you informed. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Wed Nov 03, 2021 2:40 am

Hello Omur,

Hope you are doing well.
After further investigations, you can use this line : chart.Series.Append(chart.ChartData[0, 4]); to replace the line: chart.Series.SeriesLabel = chart.ChartData["B1", "E1"]; to achieve your demand.
Here is all the code:
Code: Select all
            //Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("C:/multi.series.test.pptx");


            //Get first slide from template presentation
            var slide = templatePresentation.Slides[0];

            //Get Chart                       
            IChart chart = slide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Chart 5") as IChart;


            chart.ChartData[1, 0].Value = "car 1";
            chart.ChartData[2, 0].Value = "car 2";
            chart.ChartData[3, 0].Value = "car 3";
            chart.ChartData[4, 0].Value = "car 4";
            chart.ChartData[5, 0].Value = "car 5";


            chart.ChartData[0, 1].Value = "brand 1";
            chart.ChartData[0, 2].Value = "brand 2";
            chart.ChartData[0, 3].Value = "brand 3";
            chart.ChartData[0, 4].Value = "brand 4";

            chart.ChartData[1, 1].Value = 50;
            chart.ChartData[2, 1].Value = 60;
            chart.ChartData[3, 1].Value = 40;
            chart.ChartData[4, 1].Value = 60;
            chart.ChartData[5, 1].Value = 50;

            chart.ChartData[1, 2].Value = 55;
            chart.ChartData[2, 2].Value = 45;
            chart.ChartData[3, 2].Value = 35;
            chart.ChartData[4, 2].Value = 25;
            chart.ChartData[5, 2].Value = 14;

            chart.ChartData[1, 3].Value = 20;
            chart.ChartData[2, 3].Value = 30;
            chart.ChartData[3, 3].Value = 40;
            chart.ChartData[4, 3].Value = 10;
            chart.ChartData[5, 3].Value = 20;

            chart.ChartData[1, 4].Value = 20;
            chart.ChartData[2, 4].Value = 20;
            chart.ChartData[3, 4].Value = 20;
            chart.ChartData[4, 4].Value = 20;
            chart.ChartData[5, 4].Value = 20;

            ////Set series labels
            //chart.Series.SeriesLabel = chart.ChartData["B1", "E1"];
            chart.Series.Append(chart.ChartData[0, 4]);
            //Select data               
            chart.Series[0].Values = chart.ChartData["B2", "B6"];
            chart.Series[1].Values = chart.ChartData["C2", "C6"];
            chart.Series[2].Values = chart.ChartData["D2", "D6"];
            chart.Series[3].Values = chart.ChartData["E2", "E6"];

            //Save and launch to view the PPTX document.
            templatePresentation.SaveToFile("C:/multi.series.test.result.case3.pptx", Spire.Presentation.FileFormat.Pptx2013);

In addition, our developer has modified SET method of chart.Series.SeriesLabel. When new version is released, we will inform you.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Tue Sep 13, 2022 5:15 am

Hello Omur,

Thanks for your patient waiting.
I'm glad to inform you that our latest Spire.Presentation Pack Version:7.8 have added "chart.Series.KeepSeriesFormat = true" to keep the series format. Welcome to download it from the following links and refer to the following code to test.
Websitelink: https://www.e-iceblue.com/Download/download-presentation-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/
Code: Select all
//Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("multi.series.test.pptx");


            //Get first slide from template presentation
            var slide = templatePresentation.Slides[0];

            //Get Chart                       
            IChart chart = slide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Chart 5") as IChart;


            chart.ChartData[1, 0].Value = "car 1";
            chart.ChartData[2, 0].Value = "car 2";
            chart.ChartData[3, 0].Value = "car 3";
            chart.ChartData[4, 0].Value = "car 4";
            chart.ChartData[5, 0].Value = "car 5";


            chart.ChartData[0, 1].Value = "brand 1";
            chart.ChartData[0, 2].Value = "brand 2";
            chart.ChartData[0, 3].Value = "brand 3";
            chart.ChartData[0, 4].Value = "brand 4";

            chart.ChartData[1, 1].Value = 50;
            chart.ChartData[2, 1].Value = 60;
            chart.ChartData[3, 1].Value = 40;
            chart.ChartData[4, 1].Value = 60;
            chart.ChartData[5, 1].Value = 50;

            chart.ChartData[1, 2].Value = 55;
            chart.ChartData[2, 2].Value = 45;
            chart.ChartData[3, 2].Value = 35;
            chart.ChartData[4, 2].Value = 25;
            chart.ChartData[5, 2].Value = 14;

            chart.ChartData[1, 3].Value = 20;
            chart.ChartData[2, 3].Value = 30;
            chart.ChartData[3, 3].Value = 40;
            chart.ChartData[4, 3].Value = 10;
            chart.ChartData[5, 3].Value = 20;

            chart.ChartData[1, 4].Value = 20;
            chart.ChartData[2, 4].Value = 20;
            chart.ChartData[3, 4].Value = 20;
            chart.ChartData[4, 4].Value = 20;
            chart.ChartData[5, 4].Value = 20;

            chart.Series.KeepSeriesFormat = true;
            //Set series labels
            chart.Series.SeriesLabel = chart.ChartData["B1", "E1"];

            //Select data               
            chart.Series[0].Values = chart.ChartData["B2", "B6"];
            chart.Series[1].Values = chart.ChartData["C2", "C6"];
            chart.Series[2].Values = chart.ChartData["D2", "D6"];
            chart.Series[3].Values = chart.ChartData["E2", "E6"];

            //Save and launch to view the PPTX document.
            templatePresentation.SaveToFile("multi.series.test.result.case3.pptx", Spire.Presentation.FileFormat.Pptx2013);


Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation