If Tables("电解电容").Current Is Nothing Then Return
Dim count As Integer = Tables("电解电容").Current("零缺陷数量")
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))
sheet(62+i, 10).value = nums2(Rand.Next(count))
sheet(62+i, 18).value = nums3(Rand.Next(count))
Next
For i As Integer = 31 To 60
If i > count Then Exit For
sheet(32+i, 6).value = nums1(Rand.Next(count))
sheet(32+i, 14).value = nums2(Rand.Next(count))
sheet(32+i, 22).value = nums3(Rand.Next(count))
Next
For i As Integer = 61 To 90
If i > count Then Exit For
sheet(99+i, 2).value = nums1(Rand.Next(count))
sheet(99+i, 10).value = nums2(Rand.Next(count))
sheet(99+i, 18).value = nums3(Rand.Next(count))
Next
For i As Integer = 91 To 120
If i > count Then Exit For
sheet(62+i, 6).value = nums1(Rand.Next(count))
sheet(62+i, 14).value = nums2(Rand.Next(count))
sheet(62+i, 22).value = nums3(Rand.Next(count))
Next
Book.Build() '生成报表
Book.Save(fl)
'book.save(dfile)
Dim proc As new Process
proc.File = fl
proc.Start