简体   繁体   English

如何使用C#更改Excel数据标签的背景颜色

[英]How to change the background color of excel data label using C#

I am trying to change the shape of excel data label using C#. 我正在尝试使用C#更改excel 数据标签的形状。 But I am stuck with interop Fill Property . 但是我对互操作填充属性感到困惑。

Not able to understand at all how to use it and also how can I change the shape of data label using this. 完全不了解如何使用它,以及如何使用此方法更改数据标签的形状。 If anyone has any idea Please help. 如果有人有任何想法请帮助。

Your help will be appreciated. 您的帮助将不胜感激。 I am using it in Line chart. 我在折线图中使用它。

I have tried this so far- 到目前为止,我已经尝试过了

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.Fill = ????;//here I am stuck
    }
}

Your line: pt.DataLabel.Fill = ????; //here I am stuck 您的行: pt.DataLabel.Fill = ????; //here I am stuck pt.DataLabel.Fill = ????; //here I am stuck

You need this: pt.DataLabel.Format.Fill.ForeColor.RGB = ??? 您需pt.DataLabel.Format.Fill.ForeColor.RGB = ???pt.DataLabel.Format.Fill.ForeColor.RGB = ???

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM