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

Free Support Forum - aspose.com

Custom Numeric Format Is Not Working for HTML Result but Works for PPT

Hi Team,

I am using Aspose Slides for .NET version 22.11.0. I am trying to read cell value & formatting details from excel source file and setting those values for dynamic Chart in pptx file.
When we try to export the result in ppt it’s working fine but with the html result custom formatting is not working.
Note: Please have a look on attached zip file which contains

  1. Error.png
  2. PPTResult.pptx
  3. HTMLResult.html
  4. ReportTemplate.pptx

OS Version: Windows 10 Enterprise 64-bit
.NET Framework version: 4.8

Sample Code

public void GetHtmlResult()
{
    try
    {
        string path = @"C:\Users\admin\ReportTemplate.pptx";
        byte[] byteFile = System.IO.File.ReadAllBytes(path);
        MemoryStream reportTemplateStream = new MemoryStream(byteFile);
        using (Presentation presentation = new Presentation(reportTemplateStream))
        {
            ISlide slide = presentation.Slides[0];
            IChart currentChart = slide.Shapes[0] as IChart;
            IChartDataWorkbook chartWorkbook = currentChart.ChartData.ChartDataWorkbook;
            if (slide.Shapes[0].AlternativeText.Split('\n')[0].Contains("SOURCE"))
            {
                //This method is used to read data from source file and copy it into chartworkbook
                //CopySourceDataToChartWorkBook(chartWorkbook);
                foreach (ChartSeries ser in currentChart.ChartData.Series)
                {
                    ser.Labels.DefaultDataLabelFormat.IsNumberFormatLinkedToSource = true;

                    foreach (IDataLabel dataLabel in ser.Labels)
                    {
                        dataLabel.DataLabelFormat.IsNumberFormatLinkedToSource = true;
                    }

                    string valueNumberFormat = string.Empty;
                    string xValueNumberFormat = string.Empty;
                    string yValueNumberFormat = string.Empty;

                    foreach (IChartDataPoint dp in ser.DataPoints)
                    {
                        dp.Label.DataLabelFormat.IsNumberFormatLinkedToSource = true;
                        if (dp != null)
                        {
                            if (dp.Value != null && dp.Value.AsCell != null)
                            {
                                valueNumberFormat = dp.Value.AsCell.CustomNumberFormat;
                            }
                            if (dp.XValue != null && dp.XValue.AsCell != null)
                            {
                                xValueNumberFormat = dp.XValue.AsCell.CustomNumberFormat;
                            }
                            if (dp.YValue != null && dp.YValue.AsCell != null)
                            {
                                yValueNumberFormat = dp.YValue.AsCell.CustomNumberFormat;
                            }
                        }
                    }

                    if (!string.IsNullOrEmpty(valueNumberFormat))
                    {
                        ser.NumberFormatOfValues = valueNumberFormat;
                    }
                    if (!string.IsNullOrEmpty(xValueNumberFormat))
                    {
                        ser.NumberFormatOfXValues = xValueNumberFormat;
                    }
                    if (!string.IsNullOrEmpty(yValueNumberFormat))
                    {
                        ser.NumberFormatOfYValues = yValueNumberFormat;
                    }
                }

                //Similarly we are setting the Horizontal Axis Number Format
                //string format = ""; //Get Format from the Excel source file
                //IAxis axis = currentChart.Axes.HorizontalAxis;
                //axis.NumberFormat = format;
                //axis.IsNumberFormatLinkedToSource = false;
            }

            ResponsiveHtmlController controller = new ResponsiveHtmlController();
            HtmlOptions htmlOptions = new HtmlOptions
            {
                HtmlFormatter = HtmlFormatter.CreateCustomFormatter(controller)
            };
            presentation.Save(@"C:\Users\rkumarpa\source\repos\ErrorBulletChart\ErrorBulletChart\Docs\Output.html", SaveFormat.Html, htmlOptions);
        }
    }
    catch (Exception ex)
    {

    }
}

Attachment.zip (293.0 KB)

@rkumarpa,
Thank you for contacting support.

Unfortunately, my results look different. output_files.zip (56.8 KB)
Could you please carefully check your results again?

Hi Andrey,
I just modified my code. Could you check once more ?

@rkumarpa,
I will get back to you as soon as possible. Thank you for your patience.

@rkumarpa,
I have the same result for both HTML and PPTX documents. output.zip (116.4 KB).
We need more information on how to reproduce the problem.