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.

Tue Apr 11, 2017 2:33 pm

Dear Team,

When I load a slide into c# from a premade powerpoint, I seem to not be able to read the formatting of the text in x and y axis, aswell as legend.

I access these fields:

Code: Select all
foreach (var legend in iChart.ChartLegend.EntryTextProperties)
            {
                legend.FontHeight = DataHolder.LegendFontSize;
                legend.LatinFont = new TextFont(DataHolder.LegendFont);
                legend.Fill.SolidColor.Color = DataHolder.LegendColor;
            }

            if (iChart.PrimaryCategoryAxis == null) return;
           
            iChart.PrimaryCategoryAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = DataHolder.PrimaryValueAxisColor;
            iChart.PrimaryCategoryAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
            iChart.PrimaryCategoryAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = DataHolder.PrimaryCategoryAxisFontSize;
            iChart.PrimaryCategoryAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.LatinFont = new TextFont(DataHolder.PrimaryValueAxisFont);

            if (iChart.PrimaryValueAxis == null) return;

            iChart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.SolidColor.Color = DataHolder.PrimaryCategoryAxisColor;
            iChart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.Fill.FillType = FillFormatType.Solid;
            iChart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.FontHeight = DataHolder.PrimaryValueAxisFontSize;
            iChart.PrimaryValueAxis.TextProperties.Paragraphs[0].DefaultCharacterProperties.LatinFont = new TextFont(DataHolder.PrimaryCategoryAxisFont);


And they are all either null, NaN or default values. Should I not be able to read the values set in the powerpoint, so I do not need to set these things programmatically?

The goal is to pretty much only insert data from my code, and have a template where the format can be changed freely, without having to change the code.

I have similar issues with formatting of seriesdata, so I'm wondering if I need to set a flag somewhere, to keep the formatting of the loaded shapes, since it seems that atm. everything is reset to the master template.

Archigo
 
Posts: 21
Joined: Tue Apr 11, 2017 2:00 pm

Wed Apr 12, 2017 7:51 am

Hello,

Thanks for your inquiry.
It's hard to give you an accurate solution without the chart type information and some settings related. Concerning this, could you please share your sample ppt so we can have a better investigation.

Many Thanks,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu Apr 13, 2017 11:43 am

I am using pie charts and column charts, like the ones you see below. I can post a real ppt template if necessary, next week.

In the code, both the pie chart and the column chart are handled as "IChart" types. If I set any formatting on the legend or the X and Y axis, such as text size or text color, this disappears when i have loaded them into code, added content and saved them. The same happens if I try to do add special fill types on the columns in the column chart.

I'm using the trial version of spire, if that makes any difference, since we're so far testing if spire works better for us than our old solution.

Image
Image

Archigo
 
Posts: 21
Joined: Tue Apr 11, 2017 2:00 pm

Fri Apr 14, 2017 2:43 am

Hello,

Thanks for your reply.
Please use the following code to format the text on the legend.
Code: Select all
for (int i = 0; i < iChart.ChartLegend.TextProperties.Paragraphs.Count; i++)
            {
                iChart.ChartLegend.TextProperties.Paragraphs[i].DefaultCharacterProperties.Format.FontHeight = 20;
                iChart.ChartLegend.TextProperties.Paragraphs[i].DefaultCharacterProperties.Format.LatinFont = new TextFont("Arial Unicode MS");
                iChart.ChartLegend.TextProperties.Paragraphs[i].DefaultCharacterProperties.Format.Fill.SolidColor.Color = Color.Red;
            }

As for the formatting on the x and y Axis, your code works well with column chart. Since there's no x and y Axis in the pie chart, the setting makes no sense.
If there's still any doubt, do not hesitate to write back.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Tue Apr 18, 2017 9:31 am

Thanks for the help. Your code allowed me to achieve what I want

Archigo
 
Posts: 21
Joined: Tue Apr 11, 2017 2:00 pm

Wed Apr 19, 2017 2:01 am

Hello,

Thanks for the feedback!
Please feel free to contact us if there's any question.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.Presentation