日期:2014-05-20 浏览次数:21017 次
public void InsertActiveChart(Excel.XlChartType ChartType, string ws, int DataSourcesX1, int DataSourcesY1, int DataSourcesX2, int DataSourcesY2, Excel.XlRowCol ChartDataType)//插入图表操作
{
ChartDataType = Excel.XlRowCol.xlColumns;
wb.Charts.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
{
string StartColumn = GetColumnName(DataSourcesX1);
string EndColumn = GetColumnName(DataSourcesX2);
wb.ActiveChart.ChartType = ChartType;
wb.ActiveChart.SetSourceData(GetSheet(ws).get_Range(StartColumn + DataSourcesY1.ToString(), EndColumn + DataSourcesY2.ToString()));
wb.ActiveChart.Location(Excel.XlChartLocation.xlLocationAsObject, ws);
}
}
//插入图表
excel.InsertActiveChart(Excel.XlChartType.xlLine, "Sheet1", 1, 1, 15, 3, Excel.XlRowCol.xlColumns);
excel.InsertActiveChart(Excel.XlChartType.xlLine, "Sheet1", 1, 20, 15, 23, Excel.XlRowCol.xlColumns);