关于excel导入数据库的问题?
程序如下:Private Sub Command1_Click()
Screen.MousePointer = vbHourglass
Dim cellvalue As String
Dim excelapp As Excel.Application
Dim excelbook As Excel.Workbook
Dim excelsheet As Excel.Worksheet
Dim excelquerytable As Excel.QueryTable
Set excelapp = CreateObject("excel.application")
Set excelbook = excelapp.Workbooks().add("d:\共享\sap6818.xls")
excelapp.Visible = True
Set excelsheet = excelapp.ActiveSheet
For i = 1 To excelsheet.Rows
For j = 1 To excelsheet.Columns
cellvalue = Trim(excelsheet.Cells(i, j))
' 插入数据库
。。。。。
。。。。。。。
Next j
Next i
excelapp.Quit
Set excelapp = Nothing
Set excelbook = Nothing
Set excelsheet = Nothing
Screen.MousePointer = vbDefault
MsgBox "成功!"
End Sub
问题:
1.运行提示“内存溢出”
问题是否出在这里: For i = 1 To excelsheet.Rows,For j = 1 To excelsheet.Columns
此rows,columns非有效数据行和列
2.每次只读一个cell值,插入数据库就要一个一个列的插入,速度慢,sql语句多,
能否使用数组一次读出一行或所有数据,如果可以该怎样写代码。
(注意:表中有空值)
3.怎样把excel中的一列拆分成多列插入数据库
[此贴子已经被作者于2006-12-7 14:30:00编辑过]