在帮助文档中有数据合并导入的代码如下,如果我想先判断要导入的订单表(订单.xls)是不是每一列的每个单元格都有数据,如果数据没有空则导入,如果数据有空则提醒“数据有空白”
请问各位大神,怎么实现呢?
Dim Book As New
XLS.Book("c:\test\订单.xls")
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables("订单").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim nms() As String = {"编号","产品","客户","雇员","单价","折扣","数量","日期"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For
n
As
Integer = 1
To
Sheet.Rows.Count
-1
Dim
bh
As
String = sheet(n,0).Text
If
DataTables("订单").Find("编号 = '" &
bh
& "'") Is
Nothing
Then
'如果不存在同编号的订单
Dim r As Row = Tables("订单").AddNew()
For
m As
Integer = 0 To nms.Length - 1
r(nms(m)) =
Sheet(n,m).Value
Next
End If
Next
Tables("订单").ResumeRedraw()
[此贴子已经被作者于2020/11/11 20:36:55编辑过]