版主,请帮忙一下,以下代码不知道错在哪儿,我点选Box no打印时,选中的箱号打不出来,老是打出来空白,不知道为什么?
这是按钮代码:
DataTables("Shipment").DataCols("ShippingNo").RaiseDataColChanged()
Dim Book As New XLS.Book(ProjectPath & "Attachments\manuf shipping mark.xlsx")
Dim fl As String = ProjectPath & "manufacturing\"&Tables("shipment.packinglist").current("shippingNo")&"\Box\"& "ShippingNo_"& Tables("shipment.packinglist").current("shippingNo") & " BoxNo_" &Tables("shipment.packinglist").current("boxno") & ".xlsx"
Dim Result As DialogResult
Dim Proc As New Process '打开工作簿
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("Shipment.Packinglist").Rows.Count - 1
Dim r As Row = Tables("Shipment.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("Shipment.Packinglist").current("boxno") & "'>"
Book.Build() '生成细节区
sheet = Book.Sheets(0)
If FileSys.FileExists(ProjectPath & "manufacturing\"&Tables("shipment.packinglist").current("shippingNo")&"\Box\"& "ShippingNo_"& Tables("shipment.packinglist").current("shippingNo") & " BoxNo_" &Tables("shipment.packinglist").current("boxno") & ".xlsx") Then
Result = Messagebox.Show(Tables("shipment.packinglist").current("shippingNo") & " BoxNo_" &Tables("shipment.packinglist").current("boxno") & ".xlsx"&" 文件已经存在,是否要覆盖?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Book.Save(fl) '保存工作簿
Proc.File = fl
Proc.Start()
End If
Else
Book.Save(fl) '保存工作簿
Proc.File = fl
Proc.Start()
End If
这是表单属性代码:
Dim r1 As Row = Nothing
Dim cn1 As Integer = 0
Dim cn2 As Double = 0
Dim cn3 As Double = 0
Tables("Shipment.Packinglist").sort = "BoxNo"
For i As Integer = 0 To Tables("Shipment.Packinglist").Rows.Count - 1
Dim r As Row = Tables("Shipment.Packinglist").Rows(i)
If r1 Is Nothing OrElse r("ShippingNo") & r("BoxNo") <> r1("ShippingNo") & r1("BoxNo")
cn1 += 1
r1 = r
End If
Next
此主题相关图片如下:捕获.png