vsto画箱体图 箱线图 xlboxwhisker
using Excel=Microsoft.Office.Interop.Excel;
Excel.Chart lChart = null;
//1完美解决
//既能自动填充,又能可以有数字标签
try
{
Excel.Worksheet lSheet = Globals.ThisAddIn.Application.ActiveSheet;
Globals.ThisAddIn.Application.Range[lSheet.Cells[2, 2], lSheet.Cells[2, 12]].Select();
lChart = lSheet.Shapes.AddChart2(332, (Excel.XlChartType)121, 100, 100, 400, 500, false).Chart;
lChart.SetElement(Microsoft.Office.Core.MsoChartElementType.msoElementChartTitleAboveChart);
lChart.ChartTitle.Text = “箱体图”;
//两个参数都要传递,依然报错 但是可以画出箱体图,如果不传递第二参数 excel自动填充功能被破坏(补偿不能为1)
lChart.Location(Excel.XlChartLocation.xlLocationAsObject, “箱体图”);
}
catch (Exception ex)
{
string str = ex.Message;
}
try
{
//设置显示标签
lChart.SetElement(Microsoft.Office.Core.MsoChartElementType.msoElementDataLabelShow);
}
catch
{
}