我对使用C#在Excel中设置图表格式有一些疑问。
我有下一个代码:
#region first
Excel.Range chartRange;
Excel.ChartObjects xlCharts2 = (Excel.ChartObjects)WorkSheet_2.ChartObjects(Type.Missing);
Excel.ChartObject myChart = (Excel.ChartObject)xlCharts2.Add(1170, 710, 345, 345);
Excel.Chart chartPage = myChart.Chart;
Excel.SeriesCollection col1 = chartPage.SeriesCollection();
// chartRange = WorkSheet_2.get_Range("AH15", "AK15");
// chartPage.SetSourceData(chartRange);
chartPage.ChartArea.Border.Color = Color.FromArgb(196, 255, 0).ToArgb();
Excel.SeriesCollection chartPageseriesCollection = chartPage.SeriesCollection();
SeriesCollection seriesCollection = (SeriesCollection)chartPage.SeriesCollection(Type.Missing);
Series series = seriesCollection.NewSeries();
series.XValues = WorkSheet_2.get_Range("AH3", "AK3");
series.Values = WorkSheet_2.get_Range("AH15", "AK15");
chartPage.ChartType = Excel.XlChartType.xlPie;
chartPage.HasLegend = true;
chartPage.Legend.Border.Color = ColorTranslator.ToOle(Color.Green);
chartPage.Legend.Position = XlLegendPosition.xlLegendPositionCorner;
chartPage.Legend.Font.Name = "Arial";
chartPage.Legend.Font.Size = 10;
chartPage.HasTitle = true;
chartPage.ChartTitle.Text = "Projects";
chartPage.ChartTitle.Position = XlChartElementPosition.xlChartElementPositionAutomatic;
chartPage.ChartTitle.Font.Size = 14;
chartPage.ChartTitle.Font.Name = "Arial";
chartPage.ChartTitle.Font.Bold = true;
////////////////////////////////////////////////////////////
x3l.PlotArea(chartPage, ChartHeight * 0.30, ChartWidth * 0.06, ChartHeight * 0.7, ChartWidth * 0.7);
#endregion
在我得到这个结果之后: image with chart
所以,我不知道如何显示带有图表的第二张图像中显示的值和百分比。 image with the second chart
而且,如何更改某些值的颜色
感谢您的帮助:)