We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PPTX to HTML - CustomNumberFormat Property Does Not Work for Chart Data Point

Hi,
I am trying to format chart data points dynamically. Some times as percent with one decimal point or numbers with one decimal point.
I am using the data point CustomNumberFormat property by setting it to “0.0%”
This works when the files is saved as PPTX, but it does not when saved to HTML.
When saved to HTML the data points display as numbers with no percent sign.SligleSlideScatter.zip (154.8 KB)

I am attaching the sample input slide and the test code.

 public void TestNumberFormats()
    {

        string sosurcePath = @"C:\temp\SligleSlideScatter.pptx";
        string destinationPath = @"C:\temp\SligleSlideScatterOutput.pptx";
        string destinationHtmlPath = @"C:\temp\SligleSlideScatterOutput.html";

        Presentation p = new Presentation(sosurcePath);

        IChart  chart = p.Slides[0].Shapes[0] as IChart;

        foreach(IChartSeries ser in chart.ChartData.Series)
        {
            foreach(IChartDataPoint dp in ser.DataPoints)
            {
                if (dp.Value != null && dp.Value.AsCell != null)
                {
                    dp.Value.AsCell.CustomNumberFormat = "0.0%";
                    System.Diagnostics.Debug.Print(@"dp value custom number format {0}", dp.Value.AsCell.CustomNumberFormat);
                    System.Diagnostics.Debug.Print(@"dp value preset number format {0}", dp.Value.AsCell.PresetNumberFormat);
                }
                if (dp.XValue != null && dp.XValue.AsCell != null)
                {
                    dp.XValue.AsCell.CustomNumberFormat = "0.0%";
                    System.Diagnostics.Debug.Print(@"dp Xvalue custom number format {0}", dp.XValue.AsCell.CustomNumberFormat);
                    System.Diagnostics.Debug.Print(@"dp Xvalue preset number format {0}", dp.XValue.AsCell.PresetNumberFormat);
                }
                if (dp.YValue != null && dp.YValue.AsCell != null)
                {
                    dp.YValue.AsCell.CustomNumberFormat = "0.0%";
                    System.Diagnostics.Debug.Print(@"dp Yvalue custom number format {0}", dp.YValue.AsCell.CustomNumberFormat);
                    System.Diagnostics.Debug.Print(@"dp Yvalue preset number format {0}", dp.YValue.AsCell.PresetNumberFormat);
                }

            }
        }

        p.Save(destinationPath, SaveFormat.Pptx);
        for (int i = 0; i < p.Slides.Count; i++)
        {

            using (MemoryStream stream = new MemoryStream())
            {
                p.Save(stream, new[] { i + 1 }, SaveFormat.Html);

                stream.Position = 0;
                using (StreamReader reader = new StreamReader(stream))
                {
                    var html = reader.ReadToEnd();
                    File.WriteAllText(destinationHtmlPath, html);

                }


            }
        }
    }

Thank you.

@anarosa101,
Thank you for the issue description. I reproduced the problem and logged the issue with ID SLIDESNET-42686 in our tracking system. Our development team will investigate this case. You will be notified when it is fixed.

The issues you have found earlier (filed as SLIDESNET-42686) have been fixed in Aspose.Slides for .NET 22.3 (ZIP, MSI).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.