查找按钮代码:
Dim tbx As WinForm.TextBox = e.Form.Controls("txtFind")
Dim str As String =tbx.value
Dim dr As DataRow=DataTables("电池").Find("材料代号='" & str & "'")
If dr IsNot Nothing Then
Dim idx As Integer = Tables("电池").findrow(dr)
If idx>=0 Then
Tables("电池").Position=idx
End If
End If
If Tables("电池").Current Is Nothing Then Return
Dim count As Integer = Tables("电池").Current("零缺陷数量")
Dim count1 As Integer =10
Dim Book As New XLS.Book(ProjectPath & "Attachments\电池检验记录.xls") '打开模板
Dim fl As String = ProjectPath & "Reports\电池检验记录.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim nums1 As new List(Of String)
Dim nums2 As new List(Of String)
Dim nums3 As new List(Of String)
For Each dr As DataRow In DataTables("电池检验记录").Select("空载电压测试值 is not null")
nums1.Add(dr("空载电压测试值"))
nums2.add(dr("外形尺寸_本体长度"))
nums3.add(dr("外形尺寸_本体直径"))
Next
For i As Integer = 1 To 30
If i > count Then Exit For
sheet(62+i, 2).value = nums1(Rand.Next(count))
Next
For i As Integer = 31 To 60
If i > count Then Exit For
sheet(32+i, 7).value = nums1(Rand.Next(count))
Next
For i As Integer = 61 To 90
If i > count Then Exit For
sheet(62+i, 14).value = nums1(Rand.Next(count))
Next
For i As Integer = 91 To 120
If i > count Then Exit For
sheet(32+i, 21).value = nums1(Rand.Next(count))
Next
For s As Integer =0 To 5
sheet(56,6+4*s).value = nums2(Rand.Next(count))
sheet(57,6+4*s).value = nums3(Rand.Next(count))
Next
For s As Integer = 6 To 10
sheet(59,2+4*(s-5)).value = nums2(Rand.Next(count))
sheet(60,2+4*(s-5)).value = nums3(Rand.Next(count))
Next
Book.Build() '生成报表
Book.Save(fl)
'book.save(dfile)
Dim proc As new Process
proc.File = fl
proc.Start