如何在vsto word addin中更改excel图表的样式?

时间:2016-07-11 10:16:12

标签: vsto

如何更改样式以及如何使x轴和y轴以不同的颜色加粗?

Word.Chart wdChart = doc.InlineShapes.AddChart(Microsoft.Office.Core.XlChartType.xlColumnClustered, ref missing).Chart;

wdChart.Legend.LegendEntries(wdChart.Legend.LegendEntries().Count).Delete();
wdChart.Legend.Clear();
wdChart.ChartStyle = 311;

Word.ChartData chartData = wdChart.ChartData;
Excel.Workbook dataWorkbook = (Excel.Workbook)chartData.Workbook;
Excel.Worksheet dataSheet = (Excel.Worksheet)dataWorkbook.Worksheets[1];


//wdChart.ChartTitle.Text = String.Empty;

dataWorkbook.Application.Visible = false;

for (int i = 0; i < xData.Count; i++)
{
    ((Excel.Range)dataSheet.Cells.get_Range("A" + (i + 2).ToString(), missing)).FormulaR1C1 = xData[i].ToString();
    ((Excel.Range)dataSheet.Cells.get_Range("B" + (i + 2).ToString(), missing)).FormulaR1C1 = yData[i].ToString();
    ((Excel.Range)dataSheet.Cells.get_Range("C" + (i + 2).ToString(), missing)).FormulaR1C1 = zData[i].ToString();

}

wdChart.HasTitle = false;
dataWorkbook.Application.Quit();

0 个答案:

没有答案