1、调用dev的几个dll便于图形绘制和excel外部数据加载
2、加载指定路径下的excel文件
如下函数
openexcel文件如下:
指定路径用相对路径或者绝对路径
//string excelpath = string.Empty;
//string filePath = Application.StartupPath + "\\excel文件路径";// FileDialogHelper.OpenExcel();
//IWorkbook workbook = spreadsheetControl1.Document;
//if (!string.IsNullOrEmpty(filePath))
//{
// workbook.LoadDocument(filePath + "\\chartDemo.xlsx");
//}
3、然后根据加载的excel绘制图形,可以绘制多种类型的图形
#region #PieChart
Worksheet worksheet = workbook.Worksheets["chartTask1"];
workbook.Worksheets.ActiveWorksheet = worksheet;
// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.PieExploded, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["K15"];
// Set the chart style.
chart.Style = ChartStyle.ColorGradient;
// Hide the legend.
chart.Legend.Visible = false;
// Rotate the pie chart view.
chart.Views[0].FirstSliceAngle = 100;
// Display data labels.
DataLabelOptions dataLabels = chart.Views[0].DataLabels;
dataLabels.ShowCategoryName = true;
dataLabels.ShowPercent = true;
dataLabels.Separator = "\n";
#endregion #PieChart
后续其他绘制的chart 可以下载附件进行查看