主题:菜鸟请教:如何将EXCEL导入到数据库或DATAGRID?
heyihy
[专家分:0] 发布于 2005-10-26 10:15:00
[em18]
回复列表 (共2个回复)
沙发
williambolice [专家分:470] 发布于 2005-11-01 02:53:00
以单元格的形式填充即可,
例如
DataGrid1.Items[i].cells[1]=excel[i+1][1]
板凳
youufis [专家分:20] 发布于 2005-11-01 16:17:00
Dim s As String = TextBox1.Text 'EXCEL粘贴到文本框中的内容
Dim ch As String
Dim StrTmp As String
Dim FirstPos As Integer
Dim LastPos As Integer
Dim i As Integer
Dim k As Integer
FirstPos = 1
For i = 1 To Len(s)
StrTmp = Mid(s, i, 1)
If StrTmp = vbTab Then
LastPos = i
ch = Mid(s, FirstPos, (LastPos - FirstPos))
strtxt(k) = ch
k = k + 1
End If
If StrTmp = vbCr Then
k = 0
LastPos = i
ch = Mid(s, FirstPos, (LastPos - FirstPos))
If Len(ch) > 1 Then ch = Right(ch, 1)
strtxt(5) = ch
RecSave(strtxt(0), strtxt(1), strtxt(2), strtxt(3), strtxt(4), strtxt(5)) '把各字段内容存到数据库的表中
End If
If FirstPos <> 0 Then
FirstPos = LastPos
Else
FirstPos = 1
End If
我来回复