StateFilter
状态筛选,StateFilterEnum型枚举,可选值有:
Default: 显示所有行
Added : 显示新增行
Modified : 显示已经修改的行
UnChanged : 显示没有修改的行
Original: 原始视图
ModifiedOriginal: 原始视图(仅修改行)
例如在当前表显示新增行:
CurrentTable.StateFilter = StateFilterEnum.Added
导入代码如下。就是希望只把新增行加载出来。
Dim App As New MSExcel.Application
try
If Forms("正在导入").Opened = False Then
Forms("正在导入").open
End If
Dim Wb As MSExcel.Workbook = App.WorkBooks.Open("D:\物料编码.XLS")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Tables("物料编码").StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
Dim ra = ws.UsedRange
Dim nms() As String = {"物料编码","物料名称","原型物料编码","原型物料名称"}
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
For n As Integer = 2 To ra.Rows.Count
Dim wlbm As String = ws.cells(n,1).Text
If DataTables("物料编码").SQLFind("物料编码 = '" & wlbm & "'") Is Nothing Then '如果不存在同编号的计划表
Dim r As Row = Tables("物料编码").AddNew()
For m As Integer = 0 To nms.Length - 1
r(nms(m)) = ws.cells(n,m+1).Value
r.save
Next
End If
Next
Tables("物料编码").ResumeRedraw()
'DataTables("物料编码").LoadFilter = ""
'DataTables("物料编码").Load
Tables("物料编码").StateFilter = StateFilterEnum.Added
If Forms("正在导入").Opened = True Then
Forms("正在导入").close
MessageBox.show("物料编码导入完成","导入完成",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
catch ex As exception
finally
app.quit
End try