如何在数据标签C#中使用模式属性

我正在尝试使用C#来优化数据标签 。 但是我不知道FillFormat.Pattern

任何人都可以帮助我,如何使用它,并形成Excel数据标签。 您的帮助将不胜感激。

这是我迄今为止所做的。

System.Collections.IEnumerator iEChartSeries = seriesCollection.GetEnumerator(); if(iEChartSeries.MoveNext()){ var oSeries = (Excel.Series)(iEChartSeries.Current); Excel.Points pts = (Excel.Points) oSeries.Points(Type.Missing); System.Collections.IEnumerator iPoints = pts.GetEnumerator(); while(iPoints.MoveNext()) { var pt = (Excel.Point)(iPoints.Current); pt.HasDataLabel = true; pt.DataLabel.Position = Excel.XlDataLabelPosition.xlLabelPositionAbove; pt.DataLabel.Font.Name = "Arial"; pt.DataLabel.Font.FontStyle = "Bold"; pt.DataLabel.Font.Size = 8; pt.DataLabel.Text = "N"; pt.DataLabel.Format.Fill.Patterned = ??;// how to get circle/ triangle/ square shapes } } 

Patterned是一种方法,你会通过你想要的模式。 它用来设置ReadOnly属性.Pattern

语法应该按照Patterned方法,如下所述:

pt.DataLabel.Format.Fill.Patterned( msoPatternZigZag );

这里列出了不同的选项

我相信这个UI方法的自动化是通过AutoShapeType属性实现的,而不是Fill 。 看到这个post,并阅读@SiddharthRout赢得奖金的答案。

对于您的代码,请replace此行:

 pt.DataLabel.Format.Fill.Patterned = ?? 

 pt.DataLabel.Format.AutoShapeType = 105; 

105是msoShapeRectangularCallout 。 我从你对另一个答案的评论中注意到,你可能没有引用枚举所在的Microsoft.Office.Core命名空间。 神奇的数字在这里 。

HTH