以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 课程表导入 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=90780) |
||||||||
-- 作者:刘林 -- 发布时间:2016/9/21 15:35:00 -- 课程表导入 一、如何将课程表.xls的内容,星期,节次,科目导入到教务管理系统中课程表星期,节次,科目,这样可不再逐行录入。 二、将教务管理系统中的课程表做出一个像课程表.xls的结构的课程表,方便常握各班课程表。
想法有点怪异,请指导,谢谢
|
||||||||
-- 作者:刘林 -- 发布时间:2016/9/21 16:12:00 -- 课程表改成这种,在sheet1中是课程表明细,sheet2是任课教师,请问窗口中设计一个方案直接将xls中的,班级,星期,节次,科目,任课教师导入表,再根据课程表记录生成班级二维课程表,请各位高手指点,谢谢!
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/9/21 16:29:00 -- 手动导入参考:http://www.foxtable.com/webhelp/scr/2334.htm |
||||||||
-- 作者:刘林 -- 发布时间:2016/9/21 17:30:00 -- 改不出来,请指教,谢谢 |
||||||||
-- 作者:刘林 -- 发布时间:2016/9/21 20:04:00 -- Dim Book As New XLS.Book("c:\\test\\课程表.xls") 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,0).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() 改不对,没达到目的.请帮改一下,谢谢
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/9/21 21:05:00 -- 首先,去掉Execl文件,E-F列的合并单元格 代码 Dim Book As New XLS.Book("D:\\问题\\课程表.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("课程表").StopRedraw() Dim dr As Row For n As Integer = 2 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,0).Value Dim jc As String = Sheet(n,1).Value For m As Integer = 2 To 6 dr = Tables("课程表").AddNew dr("班级") = bj dr("节次") = jc dr("星期") = m-1 dr("科目") = Sheet(n,m).Value Next Next Tables("课程表").ResumeRedraw() |
||||||||
-- 作者:刘林 -- 发布时间:2016/9/22 8: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() For n As Integer = 2 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,2).Value Dim jc As String = Sheet(n,3).Value Dim mc As String = sheet(n,0).value Dim dm As String = sheet(n,1).value For m As Integer = 4 To 8 Dim dr As DataRow = DataTables("课程表").Find("班级 = \'" & bj & "\'and 星期 = \'" & cstr(m-3) & "\' and 节次 = \'" & jc & "\'") If dr Is Nothing Then \'如果不存在同编号的订单 dr = DataTables("课程表").AddNew() End If dr("学校名称") = mc dr("学校代码") = dm dr("班级") = bj dr("节次") = jc dr("星期") = cstr(m-3) dr("科目") = Sheet(n,m).Value Next Next Tables("课程表").ResumeRedraw() End If 老师,非常谢谢,通过你的指导我学到了很多,我做了个增加,但一至还有个搞不清楚,就是把课程表中的sheet(1)中教师任课表用班级对应导入课程表中的任课教师字段。请指导教,谢谢!!
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/9/22 9:01:00 -- Dim Book As New XLS.Book("F:\\H\\问题测试\\课程表.xls") Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables("课程表").StopRedraw() Dim dr As Row For n As Integer = 2 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,0).Value Dim jc As String = Sheet(n,1).Value For m As Integer = 2 To 6 dr = Tables("课程表").AddNew dr("班级") = bj dr("节次") = jc dr("星期") = m-1 dr("科目") = Sheet(n,m).Value Next Next Dim kms() As String = {"语文","数学","英语","政治","历史"} \'其它科目自己添加 Sheet = Book.Sheets(1) Dim drs As List(of DataRow) For n As Integer = 3 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,0).Value For m As Integer = 0 To kms.Length - 1 If Sheet(n,m+2).Value > "" Then drs = DataTables("课程表").Select("班级 = \'" & bj & "\' and 科目 = \'" & kms(m) & "\'") For Each r As DataRow In drs r("任课教师") = Sheet(n,m+2).Value Next End If Next Next Tables("课程表").ResumeRedraw()
|
||||||||
-- 作者:刘林 -- 发布时间:2016/9/22 10:25: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() For n As Integer = 1 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,2).Value Dim jc As String = Sheet(n,3).Value Dim mc As String = sheet(n,0).value Dim dm As String = sheet(n,1).value For m As Integer = 4 To 8 Dim dr As DataRow = DataTables("课程表").Find("班级 = \'" & bj & "\'and 星期 = \'" & cstr(m-3) & "\' and 节次 = \'" & jc & "\'") If dr Is Nothing Then \'如果不存在同编号的订单 dr = DataTables("课程表").AddNew() End If dr("学校名称") = mc dr("学校代码") = dm dr("班级") = bj dr("节次") = jc dr("星期") = cstr(m-3) dr("科目") = Sheet(n,m).Value Next Next Dim kms() As String = {"语文","数学","英语","政治","历史","生物","地理","物理","化学","音乐","美术","体育","班会","微机"} \'其它科目自己添加 Sheet = Book.Sheets(1) Dim drs As List(of DataRow) For n As Integer = 3 To Sheet.Rows.Count -1 Dim bj As String = Sheet(n,0).Value For m As Integer = 0 To kms.Length - 1 If Sheet(n,m+1).Value > "" Then drs = DataTables("课程表").Select("班级 = \'" & bj & "\' and 科目 = \'" & kms(m) & "\'") For Each r As DataRow In drs r("任课教师") = Sheet(n,m+2).Value Next End If Next Next Tables("课程表").ResumeRedraw() End If 老师,现在调得差不多了,但不晓得什么原因,其他教师能导入,但物理,体育教师导不进,请指导,谢谢
|
||||||||
-- 作者:有点蓝 -- 发布时间:2016/9/22 10:29:00 -- 是不是有合并单元格或者隐藏列 自己跟踪一下数据 调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm
|