以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 合并表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=89062) |
||||
-- 作者:刘林 -- 发布时间:2016/8/15 10:18:00 -- 合并表
|
||||
-- 作者:Hyphen -- 发布时间:2016/8/15 10:58:00 -- 上传Excel文件测试 |
||||
-- 作者:刘林 -- 发布时间:2016/8/15 11:54:00 -- 我把(n,0) 改为 (n,5) Dim bh As String = sheet(n,0).Text 这是因为EXCL中考号在第六列 可以了,但万一用户将EXCL中考号列放在其他任意列,为防错怎么办呢?请指教,谢谢!
|
||||
-- 作者:刘林 -- 发布时间:2016/8/15 11:56:00 -- 也就是说,能不能先判断下EXCL中考号在第几例 |
||||
-- 作者:Hyphen -- 发布时间:2016/8/15 14:34:00 -- Dim dlg As new OpenFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("成绩").StopRedraw() Dim nms() As String = {"学校代码","单位名称","年级代码","班级","学籍号","考号","姓名"} Dim i As Integer For i As Integer = 0 To Sheet.Cols.Count -1 If Sheet(0,i).Text = "考号" Then Exit For Next For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n,i).Text Dim dr As DataRow = DataTables("成绩").Find("考号 = \'" & bh & "\'") If dr Is Nothing Then \'如果不存在同考号的行 dr = DataTables("成绩").AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next Next Tables("成绩").ResumeRedraw() End If
|
||||
-- 作者:刘林 -- 发布时间:2016/8/15 14:41:00 -- For i As Integer = 0 To Sheet.Cols.Count -1 这句有错:变量i 在封闭模块中存在隐藏变量
|
||||
-- 作者:大红袍 -- 发布时间:2016/8/15 15:06:00 -- Dim dlg As new OpenFileDialog dlg.Filter = "Excel|*.xls;*.xlsx" If dlg.ShowDialog = DialogResult.OK Then Dim Book As New XLS.Book(dlg.FileName) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("成绩").StopRedraw() Dim nms() As String = {"学校代码","单位名称","年级代码","班级","学籍号","考号","姓名"} For n As Integer = 1 To Sheet.Rows.Count -1 Dim bh As String = sheet(n, 5).Text Dim xm As String = sheet(n, 6).Text Dim dr As DataRow = DataTables("成绩").Find("考号 = \'" & bh & "\' and 姓名 = \'" & xm & "\'") If dr Is Nothing Then \'如果不存在同考号的行 dr = DataTables("成绩").AddNew() End If For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next Next Tables("成绩").ResumeRedraw() End If |
||||
-- 作者:刘林 -- 发布时间:2016/8/15 17:22:00 -- 我现在问题是如何FOX表字段顺序与excl 表字段顺序不对应怎么办 如FOX字段顺序"学校代码","单位名称","年级代码","班级","学籍号","考号","姓名" 而excl字段顺序""单位名称","年级代码","学籍号","考号","姓名"学校代码","班级", 甚至更乱,根本不对应呢,主要是想容错,谢谢
|
||||
-- 作者:大红袍 -- 发布时间:2016/8/15 17:47:00 -- 参考
|
||||
-- 作者:刘林 -- 发布时间:2016/8/15 17:58:00 -- 打不开呢 |