1、合并数据
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog =DialogResult.OK Then
Dim t As Table = Tables("表B")
t.StopRedraw()
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
For n As Integer = 1 To Sheet.Rows.Count -1
Dim r As DataRow = t.DataTable.Find("第一列 = '" & sheet(n, 0).text & "'")
If r Is Nothing Then r = t.DataTable.AddNew()
For i As Integer = 0 To sheet.Cols.Count -1
Dim cname As String = sheet(0, i).text
If t.Cols.Contains(cname) Then
r(cname) = sheet(n, i).Text
End If
Next
Next
t.ResumeRedraw()
End If
2、如果要处理考试结果,可以在datacolchanged事件,写代码
If e.DataCol.name = "考试成绩" Then
If e.NewValue >= 60 Then
e.DataRow("考试结果") = "合计"
Else
e.DataRow("考试结果") = "不合计"
End If
End If