以下这个程序,是独立生成excel的图表的程序,开始使用在word2003环境下没有问题,程序正常。当使用在excel2007上就不行了,而且excel2007后在后台打开,在任务管理器上才能将其关闭,这是什么问题,需要作怎样的改变才能使用?报错:
.NET Framework 版本:2.0.50727.3655
Foxtable 版本:2014.11.11.1
错误所在事件:窗口,自检记录信息,Button7,Click
详细错误信息:
Exception from HRESULT: 0x800A03EC
程序:
Dim Book As New XLS.Book(ProjectPath & "Attachments\平衡系数.xls") '打开模板
Dim fl As String = ProjectPath & "Reports\平衡系数.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
'Sheet(3,9).Value = "<日期 = # " & Date.Today & "#>" '写入打印条件
Book.Build() '生成报表
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
'Proc.Start()
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(ProjectPath & "Reports/平衡系数.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("B6:F8"),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
[此贴子已经被作者于2015/10/9 16:14:11编辑过]