楼上说得对工程=>引用=>Microsoft Excel 9.0 Object Library 选中,确定即可
解决方案 »
- 程序退出时,unload mdiform 主窗体,所以mdi子窗体会自动全部unload吗? 如果可以自动卸载所有子窗体的话,我就不用写代码循环unload所有
- 问一下大家,这种界面效果是如何做出的呢?
- 我和OCX 在VB6中能正确使用,在VB.NET下提示未能正确注册?
- flash播放完则退出
- 讀取問題 - 急, 明天交作业,急!!大侠救命!
- 初学VB,几个简单问题
- 用Printer对象如何控制卷纸式打印机的打印页长度?
- 哪位大虾有用VB访问DLL的例子,小弟多谢!!
- 设置VB 窗口透明时, 我窗口上的图片上黑色部分为什么也变为透明?
- 如何做一个模糊查询的程序!请给出一些代码作参考
- 如何在LABEL里把WORD的内容按格式显示出来呢?
- 谁能给我一个jpg图片压缩的原程序啊!
Dim j As Integer'错误
'Dim xlApp As ExcelCtl.application
Dim xlApp As Excel.applicationDim xlbook As excel.workbook
Dim xlsheet As excel.worksheet'错误
'setxlapp = CreateObject("excel.application")
set xlapp = CreateObject("excel.application")xlApp.Visible = True'错误
'setxlbook = xlApp.workbooks.Add
set xlbook = xlApp.workbooks.AddOn Error Resume Next
Set xlbook = xlApp.workbooks.addopen("d:\text2.xls")
Set xlsheet = xlbook.worksheet(1)
xlsheet.Cells(6, 1) = "i"
For i = 0 To datagirdrow
DataGrid1.Row = i
For j = 0 To 6
DataGrid1.Col = j
If IsNull(DataGrid1.text) = False Then
xlsheet.Cells(i + 5, j + 1) = DataGrid1.text
End If
Next j
Next i
Exit Sub
Dim i As Integer
Dim j As Integer'错误
'Dim xlApp As ExcelCtl.application
Dim xlApp As Excel.applicationDim xlbook As excel.workbook
Dim xlsheet As excel.worksheet'错误
'setxlapp = CreateObject("excel.application")
set xlapp = CreateObject("excel.application")xlApp.Visible = True'错误
'setxlbook = xlApp.workbooks.Add
set xlbook = xlApp.workbooks.AddOn Error Resume Next
Set xlbook = xlApp.workbooks.addopen("d:\text2.xls")
Set xlsheet = xlbook.worksheet(1)
xlsheet.Cells(6, 1) = "i"
For i = 0 To datagirdrow '这个是DataGrid1的行数吗?
'错误
'DataGrid1.Row = i
For j = 0 To 6
DataGrid1.Row = i
DataGrid1.Col = j
If IsNull(DataGrid1.text) = False Then
xlsheet.Cells(i + 5, j + 1) = DataGrid1.text
End If
Next j
Next i
Exit Sub
xlApp.SaveWorkspace
xlApp.Quit
按照两位说的方法,还是不能把DATAGRID1中的数据输到EXECL中去
这里有解决方案:http://www.5ivb.net/club/dispbbs.asp?boardID=1&ID=11813