Formatting chart axes with non-comma thousands separator (C# .NET)

We are currently trying to format the horizontal and vertical axes of a chart. We can do it successfully with a comma separator (e.g. HorizontalAxis.NumberFormat = “#,##0”; ), but are unsure how to use a European format with a ‘.’ (decimal place) as the thousands separator and a ‘,’ (comma) as the decimal separator. Is it possible to set this programmatically? Or is it possible to set the locale for the presentation or chart? Can you provide an example?

We produce charts with both types of separators, so changing the culture of the machine is not a possibility.

@statista_it,

I have observed the requirements shared and like to share that API does allow you to set the chart data number format. Please visit this documentation link for information about available options for setting chart numbers format. Please visit this documentation link for setting axis number format.

Hello Mudassir,

Thank you for your reply. I know the NumberFormat can be set, my question is more about replacing comma thousands separator with a point thousands separator, as is used in many European, African, and South American countries. Setting HorizinalAxis.NumberFormat=“#.##0”; for example, treats the number as requiring decimal places, not replacing the thousands separator.

The Java API has a CurrentThreadSettings class that sounds like it might be helpful. Does this exist in the .NET Slides API?

@statista_it,

Can you please provide the desired output presentation that you want to generate and that we may verify on our end to assist you further.

@mudassir.fayyaz,
The first screenshot shows what we currently get, with commas sitting as the thousand separator.
as_is.PNG (5.0 KB)

The second screenshot shows what we would like, with the commas replaced by decimal points as the thousands separator.
desired.PNG (5.9 KB)

@statista_it,

I have observed the images shared by you and we need to verify that if this is possible without changing culture information or not using API. A ticket with ID SLIDESNET-41999 has been created in our issue tracking system as investigation to further investigate the requirements. This thread has been linked with the issue so that you may be notified one the issue will be fixed.

Hello, this is marked as resolved. Is there a solution available?

@statista_it,

Actually, PowerPoint uses system regional setting while displaying presentation. So there is no option to manage it from Aspose.Slides. If the output is an image or PDF desired result can be achieved using following sample code:

        public void CustomizeRegionalSettingExample()
        {
            using (Presentation pres = new Presentation())
            {
                //Creating chart with required values on the axis.
                IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 500, 400);
                chart.ChartData.Series[0].DataPoints[0].Value.AsCell.Value = 100000;
                chart.Axes.VerticalAxis.NumberFormat = "#,##0.00";
                chart.Axes.VerticalAxis.IsNumberFormatLinkedToSource = false;

                CultureInfo originalCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();

                try
                {
                    //set separator manually 
                    CultureInfo newCulture = (CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
                    newCulture.NumberFormat.NumberDecimalSeparator = ",";
                    newCulture.NumberFormat.NumberGroupSeparator = ".";

                    //or instead use specific culture settings
                    //  CultureInfo newCulture = new CultureInfo("es-ES", false);

                    Thread.CurrentThread.CurrentCulture = newCulture;

                    pres.Save("output.pdf", SaveFormat.Pdf);
                    pres.Slides[0].GetThumbnail(1, 1).Save("output.png", ImageFormat.Png);
                }
                finally
                {
                    Thread.CurrentThread.CurrentCulture = originalCulture;
                }
            }
        }

Thank you, @mudassir.fayyaz!

@statista_it,

You are always welcome.

The issues you have found earlier (filed as SLIDESNET-41999) have been fixed in this update.