把数据库中的数据读到EXCEL中

把数据库中的数据读到excel文件中
把datagrid1中的起始数据及查寻结果的数据读到excel文件中时,为什么会出现行号无效。
Private Sub Command3_Click()
Dim i As Integer
Dim j As Integer
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
/'Set xlBook = xlApp.Workbooks.Add
/'On Error Resume Next
Set xlBook = xlApp.Workbooks.add /'Open("d://text2.xls")
Set xlSheet = xlBook.Worksheets(1)
xlSheet.Cells(2, 5) = "项目申请书登记表"
xlSheet.Cells(6, 1) = "项目编号"
xlSheet.Cells(6, 2) = "项目名称"
xlSheet.Cells(6, 3) = "项目负责人"
xlSheet.Cells(6, 4) = "所在单位"
xlSheet.Cells(6, 5) = "填表日期"
xlSheet.Cells(6, 6) = "立项单位"
xlSheet.Cells(6, 7) = "立项类别"
xlSheet.Cells(6, 8) = "年进展情况"
xlSheet.Cells(6, 9) = "批立项日期"
xlSheet.Cells(6, 10) = "学科门类"
xlSheet.Cells(6, 11) = "经费来源"
xlSheet.Cells(6, 12) = "年所拨经费"
xlSheet.Cells(6, 13) = "校配套经费"
xlSheet.Cells(6, 14) = "完成日期"
For i = 0 To nn - 1
DataGrid1.Row = i       ,在i=18时出错
For j = 0 To 13
DataGrid1.Col = j
If IsNull(DataGrid1.Text) = False Then
xlSheet.Cells(i + 8, j + 1) = DataGrid1.Text
End If
/'xlSheet.Cells(i + 8, j + 1) = DataGrid1.Text
Next j
Next i
Exit Sub
End Sub
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值