以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  合并功能的代码中如何整合进进度条  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=102576)

--  作者:有点色
--  发布时间:2017/6/22 14:41:00
--  
Dim dlg As New OpenFileDialog
dlg.Filter = "Excel文件|*.xls;*.xlsx"
dlg.MultiSelect = True \'允许选择多个文件
If dlg.ShowDialog =DialogResult.OK Then
    Dim p As WinForm.ProgressBar
    p = Forms("窗口1").Controls("ProgressBar1")
   
    For Each fl As String In dlg.FileName
        Dim Book As New XLS.Book(dlg.FileName)
        Dim Sheet As XLS.Sheet = Book.Sheets("台账")
        p.Maximum = sheet.Rows.Count
        p.Minimum = 0
        Tables("台账打印").StopRedraw()
        \'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
        Dim nms() As String = {"序号","学生姓名","家庭住址_区"}
        \'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
        For n As Integer = 1 To Sheet.Rows.Count -1
            \'=====直接合并打印,不排除编号重复的值,即重复合并打印=====
            \'For n As Integer = 1 To Sheet.Rows.Count -1
            Dim r As Row = Tables("台账打印").AddNew()
            For m As Integer = 0 To nms.Length - 1
                r(nms(m)) = Sheet(n,m).Value
            Next
            p.Value = n
        Next
        Tables("台账打印").ResumeRedraw()
    Next
End If