以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 为何会失效 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150065) |
||||
-- 作者:ygg8310 -- 发布时间:2020/5/19 21:48:00 -- 为何会失效 Tables("交易明细").StopRedraw() For Each file As String In filesys .GetFiles("E:\\油卡文件测试\\交易明细") If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then Dim Book As New XLS.Book(file) Dim Sheet As XLS.Sheet = Book.Sheets(0) \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 Dim nms() As String = {"卡号","持卡人","交易时间","交易类型","金额","油品","数量","单价","奖励积分","余额","地点"} \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 4 To Sheet.Rows.Count -1 If Sheet(n,0).Value = "小计" Then Continue For If Sheet(n,0).Value = "总计" Then Continue For If Sheet(n,2).Value = "无" Then Continue For If Sheet(n,3).Value = "圈存" Then Continue For Dim bh0 As String = sheet(n,0).Text Dim bh1 As String = sheet(n,1).Text Dim bh2 As String = sheet(n,2).Text Dim bh3 As String = sheet(n,3).Text Dim bh4 As String = sheet(n,4).Text Dim bh5 As String = sheet(n,5).Text Dim bh6 As String = sheet(n,6).Text Dim bh7 As String = sheet(n,7).Text Dim bh8 As String = sheet(n,8).Text Dim bh9 As String = sheet(n,9).Text Dim bh10 As String = sheet(n,10).Text If DataTables("交易明细").Find("卡号 = \'" & bh0 & "\' And 持卡人 = \'" & bh1 & "\' And 交易时间 = \'" & bh2 & "\' And 交易类型 = \'" & bh3 & "\' And 金额 = \'" & bh4 & "\' And 油品 = \'" & bh5 & "\' And 数量 = \'" & bh6 & "\' And 单价 = \'" & bh7 & "\' And 奖励积分 = \'" & bh8 & "\' And 余额 = \'" & bh9 & "\' And 地点 = \'" & bh10 & "\'") 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() End If Next
|
||||
-- 作者:有点蓝 -- 发布时间:2020/5/19 22:26:00 -- 如果是数值列,去掉表达式里的单引号。 另外可能数据有空格:Dim bh0 As String = sheet(n,0).Text.trim()
|
||||
-- 作者:ygg8310 -- 发布时间:2020/5/19 23:53:00 -- Dim bh0 As String = sheet(n,0).Text.trim() 试了一下没用 如果是数值列,去掉表达式里的单引号。 这个是指哪个列? 对了老师是不是因为双精度小数的原因? 比如单价1.26这样的是用双精度小数吧?
|
||||
-- 作者:有点蓝 -- 发布时间:2020/5/20 8:39:00 -- 比如: And 数量 = " & bh6 & " And 单价 |
||||
-- 作者:ygg8310 -- 发布时间:2020/5/20 9:27:00 -- 也没用 [此贴子已经被作者于2020/5/20 9:51:15编辑过]
|
||||
-- 作者:ygg8310 -- 发布时间:2020/5/20 9:52:00 -- 是不是For n As Integer = 4 To Sheet.Rows.Count -1 For m As Integer = 0 To nms.Length - 1 的原因? |
||||
-- 作者:ygg8310 -- 发布时间:2020/5/20 9:54:00 -- 或者是不是Dim bh9 As String = sheet(n,9).Text \'余额 这个的原因? 不能用String 或者Text?
|
||||
-- 作者:有点蓝 -- 发布时间:2020/5/20 9:56:00 -- 请上传实例说明 |
||||
-- 作者:ygg8310 -- 发布时间:2020/5/20 10:16:00 --
就这个
|
||||
-- 作者:ygg8310 -- 发布时间:2020/5/20 12:18:00 -- 就是点一次还行,点击第二次又重复执行,哪路大神能帮我破解一下? |