VBNET操作excel问题

www1970 2006-09-02 11:31:28
1、使用VBNET2005调用excel2007,加入excel引用后
excelBook = excelApp.Workbooks.Open(m_filenameHor)提示重载失败,在对象浏览器中搜索,看到excelAPP只有一个open函数,但是从代码处点鼠标右键,转到定义处,就会出现两个open函数,但是一个是灰的,两个函数的参数不同,不知这个函数从哪里来?只好用
excelBook = excelApp.Workbooks.Open(m_filenameHor, , , , , , , , , , , , , , )语句。
2、excel的关闭
采用下列语句关闭启开的excel,发现,第一次的excel程序能关闭,但进程中还有,但是从第二次开始就都能关闭了,不知为什么?
If Not excelApp Is Nothing Then
excelApp.Quit()
ReleaseComObject(excelApp)
End If
''强制回收内存
GC.Collect()
...全文
156 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
www1970 2006-09-04
  • 打赏
  • 举报
回复
If Not excelRange Is Nothing Then
excelRange = Nothing
End If

If Not excelSheet Is Nothing Then
excelSheet = Nothing
End If

If Not excelBook Is Nothing Then
excelBook.Close()
excelBook = Nothing
End If
If Not excelApp Is Nothing Then
excelApp.Quit()
excelApp = Nothing
End If
GC.Collect()

都写了
whcSpring 2006-09-02
  • 打赏
  • 举报
回复
当你引用完后在后面加这条语句 第二个问题就可解决
xlbook.Close

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧