以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助][求助]如何把“任课表”中各班的班任和科任的姓名导入“学籍表”中相应单元格 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=72549) |
||||||||
-- 作者:方丈 -- 发布时间:2015/7/31 23:40:00 -- [求助][求助]如何把“任课表”中各班的班任和科任的姓名导入“学籍表”中相应单元格 请教: 如何把“任课表”中各班的班任和科任的姓名导到“学籍表”中相应单元格
[此贴子已经被作者于2015/8/1 0:03:32编辑过]
|
||||||||
-- 作者:y2287958 -- 发布时间:2015/8/1 8:26:00 -- Dim dlg As New OpenFileDialog dlg.Filter = "excel文件|*.xls" dlg.MultiSelect = True \'允许选择多个文件 If dlg.ShowDialog =DialogResult.OK Then For Each fl As String In dlg.FileNames Dim mg As New Merger mg.SourcePath = fl mg.Format = "excel" \'指定格式 mg.SourceTableName = "任课表$" mg.DataTableName = "学籍表" Dim rks As String = "政治|语文|数学|英语|物理|化学" For Each rk As String In rks.split("|") mg.FieldMaps.Add(rk,rk & "科任") Next mg.Merge() Next End If
|
||||||||
-- 作者:方丈 -- 发布时间:2015/8/1 12:48:00 -- 代码未能对应班别追加数据,谢谢二楼。 [此贴子已经被作者于2015/8/1 15:36:50编辑过]
|
||||||||
-- 作者:y2287958 -- 发布时间:2015/8/1 13:11:00 -- 表达清楚是解决问题的关键 |
||||||||
-- 作者:大红袍 -- 发布时间:2015/8/2 10:37:00 -- Dim dlg As new OpenFileDialog 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,0).Text Dim drs As List(Of DataRow) = DataTables("学籍表").Select("班级 = \'" & bh & "\'") For Each dr As DataRow In drs For m As Integer = 0 To nms.Length - 1 dr(nms(m)) = Sheet(n,m).Value Next Next Next Tables("学籍表").ResumeRedraw() End If |