参考
Dim Result As DialogResult
Result = Messagebox.Show("请先选择要导入账面数量及成本的 EXCEL 文件 是否准备好?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.NO Then '如果用户选择否
Return
End If
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "EXCEL 文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
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 dr As DataRow = DataTables("存货档案").Find("[编码] = '" & Sheet(n, 0).value & "'")
Output.Show(Sheet(n, 0).value & "****" & Sheet(n, 10).value)
If dr IsNot Nothing
If val(Sheet(n, 10).value) = 0 Then
dr("账面数量") = Nothing
dr("成本值") = Nothing
Else
dr("账面数量") = val(Sheet(n, 10).value)
dr("成本值") = val(Sheet(n, 11).value) / val(Sheet(n, 10).value)
End If
End If
Next
End If