-- 作者:szp2012
-- 发布时间:2012/10/29 2:02:00
-- 代码为何不执行
以下代码分开执行没问题,合并只执行上段,下段不执行 即窗口不出现表格
上段
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 i As Integer = 0 To Sheet.Cols.Count -1 \'Dim ct As Table=CurrentTable If Tables("工行存折历史明细").Cols.Contains( Sheet(0,i).Value) =True Then \'MessageBox.Show("目标文件不含【" & Sheet(0,i).Value & "】列,请修改与目标文件一致!", "导入错误提示") MainTable= Tables("工行存折历史明细") Return Else If Tables("兴业历史明细").Cols.Contains( Sheet(0,i).Value) Then MainTable= Tables("兴业历史明细") Return
Else If Tables("农行存折历史明细").Cols.Contains( Sheet(0,i).Value) Then MainTable= Tables("农行存折历史明细") Return
Else If Tables("深发历史明细").Cols.Contains( Sheet(0,i).Value) Then MainTable= Tables("深发历史明细") Return
Else If Tables("广州银行历史明细").Cols.Contains( Sheet(0,i).Value) Then MainTable= Tables("广州银行历史明细") Return Else MessageBox.Show("目标文件不含【" & Sheet(0,i).Value & "】列,请修改与目标文件一致!", "导入错误提示")
End If
Next MainTable=CurrentTable Dim Filter1 As String For r As Integer = 1 To Sheet.Rows.Count - 1 Filter1 = "" For c As Integer = 0 To Sheet.Cols.Count - 1 If c > 0 Then Filter1 = Filter1 & " And " End If If CurrentTable.DataTable.DataCols(sheet(0,c).Value).Isnumeric Then If sheet(r,c).Value = "" Then Filter1 = Filter1 & sheet(0,c).Value & " is null" Else Filter1 = Filter1 & sheet(0,c).Value & " = " & sheet(r,c).Value End If Else If sheet(r,c).Value = "" Then Filter1 = Filter1 & sheet(0,c).Value & " is null" Else Filter1 = Filter1 & sheet(0,c).Value & " = \'" & sheet(r,c).Value & "\'" End If End If Next If CurrentTable.DataTable.Find(Filter1) Is Nothing Then Dim dr As Row = CurrentTable.AddNew() For c As Integer = 0 To Sheet.Cols.Count - 1 dr(Sheet(0,c).Value) = Sheet(r,c).Value Next End If Next End If
下段:‘在窗口显示表格,屏蔽上段代码执行没问题,合并则下段不执行 Dim tbl As WinForm.Table tbl = e.Form.CreateTable("Table1", "广州银行历史明细",True) tbl.SetBounds(11,150, 861, 328) e.Form.AddControl(tbl)
请教原因
[此贴子已经被作者于2012-10-29 2:03:09编辑过]
|