这个问题并不是一直出现, 有时候出现,刚才我又执行了一次,正常运行了.
下面是程序段:
'ImportGDPErrorList 导入GDP Error List.xlsx
Dim s1 As Date = Date.Now
Dim s2 As Date
Dim s3 As TimeSpan
Dim cg As Boolean = True
Dim TableN As String = "GDPList"
Dim yn As Integer
If Not DataTables.Contains(TableN) Then
yn = 1
DataTables.Load(TableN)
DataTables(TableN).LoadFilter = ""
DataTables(TableN).Load
End If
Tables(TableN).StopRedraw '停止屏幕刷新
Dim fp As String = "P:\General documents\Worktime Data\Fox Data\Query\"
Dim ff = "GDP Error List.xlsx"
Dim fpf As String = fp & ff
If filesys.FileExists(fpf) Then
Dim cn As String '列名称
Dim i As Integer
Dim App As New MSExcel.Application
App.DisplayAlerts = False
App.visible = True
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fpf)
Wb.RefreshAll
'MessageBox.Show(1)
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim ary = Rg.value
Dim cs As Integer = Rg.Columns.Count
Dim c As Integer
Dim Dic_Ex As New Dictionary(Of DataRow, Integer)
cs = 13
Dim i1 As Integer = 0
Dim Filter As String
For i = 2 To Rg.Rows.Count
'MessageBox.Show(i & "/" & Rg.Rows.Count & ", 姓名:" & ary(i,3))
If ary(i, 3) > "" Then '姓名'AndAlso ary(i, 3) = "姓名"
Filter = "[Date]=# " & ary(i, 1) & "# and [姓名]='" & ary(I, 3).trim & "' and [工单号] = '" & ary(i, 5).trim & "' and [问题描述]='" & ary(i, 8).trim & "'"
'Output.Show(Filter)
Dim dr As DataRow = DataTables(TableN).Find(Filter)
If dr Is Nothing Then '新增数据行
Dim ro As DataRow = DataTables(TableN).AddNew
For c = 1 To cs
cn = ary(1, c) '列名
'Output.Show(cn & ":" & ary(i,c))
ro(cn) = ary(i, c)
Next
i1 = i1 + 1
End If
End If
Next
Tables(TableN).ResumeRedraw '停止屏幕刷新
If i1 > 0 Then
DataTables(TableN).Save
End If
If yn = 1 Then DataTables.Unload(TableN)
App.quit
End If
s2 = Date.Now
S3 = s2 - s1
Output.Show(s1 & " -- " & s2 & " 文件ImportGDPErrorList刷新经过时间s:" & s3.TotalSeconds)
Dim dr1 As DataRow = DataTables("Data").Find("文件更新_文件名 = '" & ff & "'")
dr1("文件更新_时间") = Date.Now
dr1("SpentTime") = Round2(s3.TotalSeconds, 2)
dr1.Save
[此贴子已经被作者于2023/11/18 16:05:12编辑过]