求助,狐表中表A第一列,导入外部Excel表A的第一列,如果狐表中表A第一列,已含有Excel表A的第一列的值,就跳过不导入,下面代码怎么修改?
下面代码是把Excel表全部行都进来了
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
If dlg.ShowDialog = DialogResult.OK Then
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("表A").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"第一列","试题号","题型","题目",“”,“”,“”,"分类","选择题_A","选择题_B","选择题_C","选择题_D","判断题_A","判断题_B","正确表A"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 1 To Sheet.Rows.Count -1
Dim r As Row = Tables("表A").AddNew()
For m As Integer = 0 To nms.Length - 1
if nms(m) > "" then
r(nms(m)) = Sheet(n,m).Value
end if
Next
Next
Tables("表A").ResumeRedraw()
End If
[此贴子已经被作者于2022/4/3 17:51:34编辑过]