代码如下:标红部分的代码执行效率非常低,麻烦老师给看一下如何优化?
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
If ary IsNot Nothing Then '2016-8-22 判断EXCEL不能为空
lbl8.text = "行:" & rg.Rows.Count & "," & "列:" & rg.Columns.Count
For i As Integer = 1 To rg.Rows.Count
For j As Integer = 1 To rg.Columns.Count
If ary(i,j) <> Nothing Then
If Cbox1.Checked = True AndAlso Cbox2.Checked=True AndAlso System.Text.RegularExpressions.Regex.Match((ary(i,j)),"[\u4e00-\u9fa5]+").Tostring()>"" =True Then
Dim dr As DataRow = DataTables("翻译内容").AddNew
dr("第一列") = ary(i,j)
lbl5.text = ary(i,j)
ElseIf CBox1.Checked = True AndAlso System.Text.RegularExpressions.Regex.Match((ary(i,j)),"[\u4e00-\u9fa5]+").Tostring()>"" =True AndAlso Cbox2.Checked=False AndAlso rg.Columns(j).width <> 0 AndAlso rg.Rows(i).height <> 0 Then
Dim dr As DataRow = DataTables("表A").AddNew
dr("第一列") = ary(i,j)
lbl5.text = ary(i,j)
ElseIf CBox2.Checked = True AndAlso Cbox1.Checked=False Then
Dim dr As DataRow = DataTables("表A").AddNew
dr("第一列") = ary(i,j)
lbl5.text = ary(i,j)
ElseIf cbox1.checked=False AndAlso cbox2.checked=False AndAlso rg.Columns(j).width <> 0 AndAlso rg.Rows(i).height <> 0 Then
Dim dr As DataRow = DataTables("表A").AddNew
dr("第一列") = ary(i,j)
lbl5.text = ary(i,j)
End If
End If
Next
Next
End If
Next
Wb.Close()