日期:2014-05-20 浏览次数:20906 次
Function SUVZHG() As DataTable
Dim fileName As String
Dim kk As New OpenFileDialog()
kk.FileName = "SUVZHG"
kk.Filter = "Excle恅璃(*.xls)|*.xls"
If kk.ShowDialog() = DialogResult.OK Then
fileName = kk.FileName
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & fileName & "';Extended Properties=Excel 8.0;"
Dim dr As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Try
da.Fill(dr)
SUVZHG = dr
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End If
End Function
Function TOPRC() As DataTable
Dim fileName As String
Dim kk As New OpenFileDialog()
kk.FileName = "TOPRC"
kk.Filter = "Excle恅璃(*.xls)|*.xls"
If kk.ShowDialog() = DialogResult.OK Then
fileName = kk.FileName
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & fileName & "';Extended Properties=Excel 8.0;"
Dim dr As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn)
Try
da.Fill(dr)
TOPRC = dr
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End If
End Function
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
Dim q = From emp In TOPRC() Group Join emc In SUVZHG() On emp("JSX") Equals emc("JSX") Into DataGroup = Group
From row In DataGroup.DefaultIfEmpty()
Select emp, Order = row
DG1.DataSource = q.CopyToDataTable
End Sub