質問

While I've started a thread on the Aspose forums, I thought I'd ask here as well, just in case anyone has come across the same or a similar problem while working with Aspose Slides.

I'm working with a templated chart. I've created a series, and added a label to it that I've set to display the series name.

chartData.Series.Add(chartData.ChartDataWorkbook.GetCell(0, rowIndex, columnIndex, seriesName), chartType);

// series data is set 

var label = new DataLabelEx(series) { ShowSeriesName = true };

// this next line doesn't work, as there is no portion in the first paragraph
label.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 8;

What I'd like to do now is set the font size of the label, but while all of the examples I've seen describe using the actual "Portion" object containing the text, at this time of execution, the object hasn't been created yet. As a result the series labels on my output chart have far too large a font size.

How can I set FontHeight so that it will apply to the text of my labels?

役に立ちましたか?

解決

Try the below code to set the font size of the data label.

DataLabelEx lbl = new DataLabelEx(series);
lbl.ShowSeriesName = true;
lbl.Id = 0;
PortionFormatEx pt = lbl.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat;
pt.FontHeight = 8;
series.Labels.Add(lbl);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top