Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "平衡系数.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) '指定工作表
ws.ChartObjects.Delete '删除工作表上已经存在的图表
Dim Co As MSExcel.ChartObject = Ws.ChartObjects.Add(50,160,400,250) '创建图表对象,图形位置
Dim Cht As MSExcel.Chart =Co.Chart
Cht.ChartType = MSExcel.XlChartType.xlXYScatterSmooth
Cht.SetSourceData(Ws.Range("C6:G8"),MSExcel.XlRowCol.xlRows)
With Cht.Axes(MSExcel.XlAxisType.xlCategory) '获取X轴
.HasTitle = True
.AxisTitle.Text = "载荷比例" '添加标题
.HasMajorGridlines = True '显示主要网格线
.HasMinorGridlines = True '显示次要网格线
.MinimumScale = 30
.MaximumScale = 60
.MinorUnit = 1
.MajorUnit = 5
.CrossesAt = 30
.ReversePlotOrder = False
End With
With Cht.Axes(MSExcel.XlAxisType.xlValue) '获取Y轴
.HasTitle = True
.AxisTitle.Text = "电流值" '添加标题
.HasMajorGridlines = True'显示只要网格线
.HasMinorGridlines = True'显示次要网格线
End With
App.Visible = True