【问题标题】:Set Excel chart axis title color and size in C#在 C# 中设置 Excel 图表轴标题颜色和大小
【发布时间】:2014-02-21 21:06:32
【问题描述】:

我正在动态创建一些 Excel 图表数据/系列,无法设置轴标题字体颜色/大小。

我可以使用类似于下面的代码添加轴标题:

//Gets the WorkSheet and ChartObject
Worksheet DataSheet = (Worksheet)Template.Worksheets[1];
Chart Graph = (DataSheet.ChartObjects(1) as ChartObject).Chart;

//Gets the Axes
Axis Xaxis = Graph.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary) as Axis;
Axis Y1axis = Graph.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary) as Axis;
Axis Y2axis = Graph.Axes(XlAxisType.xlValue, XlAxisGroup.xlSecondary) as Axis;

//Sets X-axis attributes
Xaxis.TickLabels.Font.Size = 8;
Xaxis.HasTitle = true;
Xaxis.AxisTitle.Text = "Current (A)";

//Sets Y-Primary Axis attributes
Y1axis.TickLabels.Font.Size = 8;
Y1axis.HasTitle = true;
Y1axis.AxisTitle.Text = "Power (W)";

//Sets Y-Secondary Axis attributes
Y2axis.TickLabels.Font.Size = 8;
Y2axis.HasTitle = true;
Y2axis.AxisTitle.Text = "Voltage (V)";

但我不知道颜色、字体大小、粗体等...属性在哪里。

【问题讨论】:

    标签: c# excel charts axis-labels


    【解决方案1】:

    又找了几个小时才找到的。

    Y1axis.AxisTitle.Format.TextFrame2.TextRange.Font.Fill.ForeColor.RGB = XlRgbColor.rgbDarkRed;
    

    我只需要再挖一点。

    【讨论】:

      猜你喜欢
      • 2020-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-08
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多