以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]修改EXCEL数据出错(已解决) (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=55839) |
-- 作者:hbydcwb -- 发布时间:2014/8/24 17:04:00 -- [求助]修改EXCEL数据出错(已解决) 以下内容为程序代码:
1 Dim t As Table = Tables("流水账_流水账") 2 Dim Filter As String 3 Dim dlg As New OpenFileDialog \'定义一个新的OpenFileDialog 4 dlg.Filter= "Excel文件|*.xls" \'设置筛选器 5 If dlg.ShowDialog = DialogResult.Ok Then \'如果用户单击了确定按钮 6 Dim Book As New XLS.Book(dlg.FileName) 7 Dim Sheet As XLS.Sheet = Book.Sheets(0) 8 For n As Integer = 7 To Sheet.Rows.Count -5 9 Filter = "[物料编码] = " & Sheet(n,0).Value 10 Dim Val1 As Double =t.DataTable.Compute("Sum(入库数量)",Filter) 11 Dim Val2 As Double = t.DataTable.Compute("Sum(出库数量)",Filter) 12 Sheet(n,5).Value = Val1 - Val2 13 Next 14 Book.Save("c:\\reports\\test.xls") 15 Dim Proc As New Process 16 Proc.File = "c:\\reports\\test.xls" 17 Proc.Start() 18 End If
出现如下错误,请老师指教!
.NET Framework 版本:2.0.50727.5483 [此贴子已经被作者于2014-8-24 17:09:01编辑过]
|
-- 作者:有点甜 -- 发布时间:2014/8/24 17:06:00 -- 1、你的物料编码要改成字符列;
2、这句
Filter = "[物料编码] = " & Sheet(n,0).Value
改成
Filter = "[物料编码] = \'" & Sheet(n,0).Value & "\'" |
-- 作者:hbydcwb -- 发布时间:2014/8/24 17:08:00 -- 解决了,谢谢甜甜老师! |