老师,
以下代码哪儿不够正确? 当我选 boxno是1 时,它还是输出boxno 是2的资料. 请见图片。另外如果我没有选中boxno 号,是不是可以提醒去选Boxno.
另外这个报表可以输出到 2018_46 这个的目录中吗? (2018是年份,46 是周期,根据现在的日期自动确定生成 ?)如果桌面上这个目录不存在就自动新建,如果存在就存在里面,里面如有这个报表,就提醒是否覆盖原来的报表 ?)
请帮忙帮忙一下,附上实例。再次感谢了。
Dim Book As New XLS.Book(ProjectPath & "Attachments\manuf shipping mark.xls")
Dim fl As String = ProjectPath & "Reports\" & Tables("packinglist").current("shippingNo") & ".xls"
Dim r1 As Row = Nothing
Dim cn1 As Integer = 0
Dim cn2 As Double = 0
Dim cn3 As Double = 0
For i As Integer = 0 To Tables("packinglist").Rows.Count - 1
Dim r As Row = Tables("packinglist").Rows(i)
If r("boxno") = r.Table.current("boxno") AndAlso (r1 Is Nothing OrElse r("ShippingNo") & r("BoxNo") <> r1("ShippingNo") & r1("BoxNo"))
cn1 += 1
cn2 += r("Volume_CBM")
cn3 += r("Gross_weight")
r1 = r
End If
Next
vars("总箱数") = cn1
vars("总立方") = cn2
vars("总毛重") = cn3
Dim Sheet As XLS.Sheet = Book.Sheets(0)
sheet(5,14).value = "<BoxNo='" & Tables("Packinglist").current("boxno") & "'>"
Book.Build() '生成细节区
sheet = Book.Sheets(0)
'Dim idx As Integer = 5
'For i As Integer = 7 To sheet.Rows.Count - 5
' If sheet(i,6).text & sheet(i,1).text <> sheet(i-1,7).text & sheet(i-1,1).text
' If i > idx +1
' For j As Integer = idx+1 To i-1
' msgbox(j & " " & idx & " " & i)
' sheet(j, 13).value = 0
' Next
Dim idx As Integer = 5
For i As Integer = 6 To sheet.Rows.Count - 5
If sheet(i,8).text <> sheet(i-1,8).text
If i > idx +1
For j As Integer = idx+1 To i-1
'msgbox(j & " " & idx & " " & i)
sheet(j, 12).value = 0
Next
Sheet.MergeCell(idx,8,i-idx,1)
Sheet.MergeCell(idx,9,i-idx,1)
Sheet.MergeCell(idx,10,i-idx,1)
Sheet.MergeCell(idx,11,i-idx,1)
Sheet.MergeCell(idx,12,i-idx,1)
End If
idx = i
End If
Next
Book.Save(fl) '保存工作簿
Dim Proc As New Process '打开工作簿
Proc.File = fl
proc.start

此主题相关图片如下:捕获1.png


此主题相关图片如下:捕获.png