execel数据导入到datagrid
请教用vb6.0实现,将execel的第一行数据导入到控件datagrid --------------------编程问答-------------------- 用vb6.0可将Excel的数据导入到控件MSFlexGrid。 --------------------编程问答-------------------- Set xl = New Excel.Applicationxl.Visible = True 'make the excel application visible
xl.Workbooks.Add
xl.Workbooks.Open ("d:\Book1.xls")
Dim rng As Range
Dim i As Integer, j As Integer
Set rng = xl.ActiveSheet.UsedRange
j = rng.Columns.Count '获取实际列数
Dim sqlstr As String
sqlstr = "select "
For i = 1 To j
sqlstr = sqlstr & " '" & rng.Cells(1, i) & "'," '获取第一行每个单元格的值
Next i
sqlstr = Left(sqlstr, Len(sqlstr) - 1)
'扫行查询
adors.Open sqlstr
Set DataGrid1.DataSource = adors
补充:VB , 资源