-- 作者:大红袍
-- 发布时间:2016/8/26 15:28:00
--
Dim st As Date = Date.Now Dim lbl As WinForm.Label = Forms("提取工具").Controls("Label6") Dim path As String = args(0) Dim lbl2 As WinForm.Label = Forms("提取工具").Controls("Label2") Dim Cbox1 As WinForm.CheckBox = Forms("提取工具").Controls("CBox") Dim Cbox2 As WinForm.CheckBox = Forms("提取工具").Controls("CBox2") Dim file As Object
Dim app As new MSExcel.Application For Each file In FileSys.GetFiles(path) try Dim wb = app.WorkBooks.Open(file) For k As Integer = 1 To wb.workSheets.Count \'//多个sheet的处理 Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(k) Dim Rg As MSExcel.Range = Ws.UsedRange Dim ary = rg.value For i As Integer = 1 To rg.Rows.Count If rg.Rows(i).height <> 0 Then For j As Integer = 1 To rg.Columns.Count If rg.Columns(j).width <> 0 Then If ary(i,j) <> Nothing Then If CBox1.Checked = True AndAlso Cbox2.Checked=False AndAlso System.Text.RegularExpressions.Regex.Match(ary(i,j),"[\\u4e00-\\u9fa5]+").Tostring()>"" Dim dr As DataRow = DataTables("表A").AddNew dr("第一列") = ary(i, j) End If End If End If Next End If Next Next Dim txt1 As WinForm.TextBox = Forms("提取工具").Controls("TextBox3") txt1.text = file & vbcrlf & txt1.text & vbcrlf Application.DoEvents() \' FileCount=FileCount+1 \'lbl.Text="已提取" & FileCount & "个文件,未提取 " & BadFileCount & "个文件" app.quit Catch ex As Exception \'MessageBox.show("当前目录不存在或文件有问题,请检查!","提示") msgbox(ex.message) Dim txt2 As WinForm.TextBox = Forms("提取工具").Controls("TextBox4") txt2.text = file & vbcrlf & txt2.text & vbcrlf \'BadFileCount =BadFileCount +1 app.quit End try Next
For Each p As String In FileSys.GetDirectories(path) Functions.Execute("提取测试", p) Next lbl2.Text="计算结束, 耗时: " & (Date.Now - st).TotalSeconds & "秒"
|