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 25, 2022 1:25 pm

When I want to reach chart data and if that chart has got hidden columns I can't reach the ChartData because it is null. I'm using Spire.Presentation 7.4.5
There is no problem with hided rows. I want to get ChartData even there are hided columns on data.

Code: Select all
//Get Chart                       
IChart chart = cloneSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Content Placeholder 15") as IChart;
chart.ChartData.Clear(0, 0, categoryCount + 1, seriesCount + 1); // chart.ChartData is null.


Template File:
template-2194-01.zip

01.jpg


But if I unhide the column manualy editing template file I can get the ChartData.

Template File:
template-2194-02.zip


Source Code:

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

namespace PptxTesterPaidVersion
{
    class Program
    {
        static void Main(string[] args)
        {
            ChartDataHideColumnProblem();
        }

        private static void ChartDataHideColumnProblem()
        {
            //Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("template-2194-01.pptx");

            //Create New Presentation
            Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation();
            presentation.Slides.RemoveAt(0);

            //Get slide from template presentation. index:1
            ISlide cloneSlide = templatePresentation.Slides.ToArray().ElementAtOrDefault(0);

            //---
            //Get Chart                       
            IChart chart = cloneSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Content Placeholder 15") as IChart;


            int seriesCount = 1;
            int categoryCount = 9;

            chart.ChartData.Clear(0, 0, categoryCount + 1, seriesCount + 1);

            chart.ChartData[1, 0].Text = "Category AA";
            chart.ChartData[2, 0].Text = "Category BB";
            chart.ChartData[3, 0].Text = "Category CC";
            chart.ChartData[4, 0].Text = "Category DD";
            chart.ChartData[5, 0].Text = "Category EE";
            chart.ChartData[6, 0].Text = "Category FF";
            chart.ChartData[7, 0].Text = "Category GG";
            chart.ChartData[8, 0].Text = "Category HH";
            chart.ChartData[9, 0].Text = "Category KK";

            chart.ChartData[0, 1].Text = "Serie 1-1";

            chart.ChartData[1, 1].NumberValue = 0.69;
            chart.ChartData[2, 1].NumberValue = 0.69;
            chart.ChartData[3, 1].NumberValue = 0.79;
            chart.ChartData[4, 1].NumberValue = 0.33;
            chart.ChartData[5, 1].NumberValue = 0.33;
            chart.ChartData[6, 1].NumberValue = 0.33;
            chart.ChartData[7, 1].NumberValue = 0.33;
            chart.ChartData[8, 1].NumberValue = 0.33;
            chart.ChartData[9, 1].NumberValue = 0.33;


            var startIndexAddSeries = chart.Series.Count + 1;
            for (int i = startIndexAddSeries; i <= 4; i++)
            {
                chart.Series.Append(chart.ChartData[0, i]);
            }
            if (chart.Series.Count > seriesCount)
            {
                for (int i = chart.Series.Count - 1; i >= seriesCount; i--)
                {
                    chart.Series.RemoveAt(i);
                }
            }
            chart.Categories.CategoryLabels = chart.ChartData["A2", "A" + (categoryCount + 1)];
            for (int i = 0; i < seriesCount; i++)
            {
                string letter = GetColumnName(i + 1);
                chart.Series[i].Values = chart.ChartData[letter + "2", letter + (categoryCount + 1)];
            }

            presentation.Slides.Append(cloneSlide);

            //Save and launch to view the PPTX document.
            presentation.SaveToFile("ChartDataHideColumnProblem_01.pptx", Spire.Presentation.FileFormat.Pptx2010);
        }


        public static string GetColumnName(int index)
        {
            const string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            var value = "";

            if (index >= letters.Length)
                value += letters[index / letters.Length - 1];

            value += letters[index % letters.Length];

            return value;
        }

        public static Color GetSlideBackgroundColor(ISlide slide)
        {
            if (slide.DisplaySlideBackground.Fill.FillType != Spire.Presentation.Drawing.FillFormatType.UnDefined)
                return slide.DisplaySlideBackground.Fill.SolidColor.Color;

            if (slide.DisplaySlideBackground.ThemeColor.ColorType != Spire.Presentation.Drawing.ColorType.None)
                return slide.DisplaySlideBackground.ThemeColor.Color;

            return Color.White;
        }
    }
}

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Tue Apr 26, 2022 6:59 am

Hello,

Thank you for your inquiry.
I tested your "template-2194-01.pptx" file and reproduced the issue you mentioned. I have logged the issue into our bug tracking system with the ticket number SPIREPPT-1932. Our development team will investigate and fix it. Once it is resolved, I will inform you in time. Sorry for the inconvenience caused.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Tue Apr 26, 2022 8:24 am

Thank you. Also it would be maybe helpful for you what I noticed that this problem started with version 7.3.1. There is no problem with version 7.2.5.

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Tue Apr 26, 2022 8:41 am

Hello,

Thank you for your survey information.
I will report this findings to our developers. Once the issue is resolved, I will inform you immediately. Thanks again for your investigation.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Wed May 11, 2022 3:49 pm

Any updates on this?

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

Thu May 12, 2022 2:12 am

Hello,

Thanks for following up.
The good news is that the issue SPIREPPT-1932 has been resolved, now it is in the testing phase. Once the tests pass, we will provide a new hotfix version for you as soon as possible. Thank you for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Mon May 23, 2022 10:08 am

Any updates on this?

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

Tue May 24, 2022 2:10 am

Hello,

Thanks for following up.
The issue SPIREPPT-1932 has been tested and we will release a new version with a fix for this issue within this month. Once the new version is available, I will let you know immediately. Thanks for your understanding.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Fri May 27, 2022 9:14 am

Hello,

Thanks for your patience!
Glad to inform you that we just released Spire.Presentation Pack Hotfix Version:7.5.3 which fixes the issue of SPIREPPT-1932.
Please download the new version from the following links to test.

Website link: https://www.e-iceblue.com/Download/download-presentation-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/7.5.3

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.Presentation