Tables("订单明细").Sort =
"订单号"
'选择全表
CurrentTable.Select(0, 0,
CurrentTable.Rows.Count - 1, CurrentTable.Cols.Count - 1)
Dim T,T1,T2,T3,T4 As String
If FileSys.FileExists(ProjectPath
& "Attachments\规格\" & Tables("订单情况").Current("IO")
& "\ " & Tables("订单情况").Current("IO")
& T3 & T2 & T4 & T &
".xls") Then
FileSys.DeleteFile(ProjectPath &
"Attachments\规格\" & Tables("订单情况").Current("IO")
& "\ " & Tables("订单情况").Current("IO")
& T3 & T2 & T4 & T & ".xls")
End If
T = e.Form.Controls("ComboBox1").value
T1 = ProjectPath &
"Attachments\" & T & ".xls"
T2 =
e.Form.Controls("ComboBox8").value
T3 =
e.Form.Controls("ComboBox5").value
T4 = e.Form.Controls("ComboBox10").value
If T IsNot Nothing Then
If T.Indexof(T) > -1 Then
Dim Book As New XLS.Book(T1)
Dim v As Double = DataTables("装箱单").Compute("Sum(箱数)","口岸
= '" & T3 & " '")
Book.Marks.Add("箱数",v)
Dim v3 As Double = DataTables("装箱单").Compute("Sum(箱数)","口岸
= '" & T2 & " '")
Book.Marks.Add("箱数1",v3)
Dim v1 As Double = DataTables("装箱单").Compute("Sum(总件数)","口岸
= '" & T3 & " '")
Book.Marks.Add("件数",v1)
Dim v2 As Double = DataTables("订单明细").Compute("Sum(TOTAL)")
Book.Marks.Add("总件数",V2 &
"PCS")
Book.Build()
Book.Save(ProjectPath &
"Attachments\规格\" & Tables("订单情况").Current("IO")
& "\" & Tables("订单情况").Current("IO")
& T3 & T2 & T4 & T & ".xls")
Dim App As New MSExcel.Application
Dim Wb As MSExcel.Workbook =
App.WorkBooks.Open(ProjectPath &
"Attachments\规格\" & Tables("订单情况").Current("IO")
& "\" & Tables("订单情况").Current("IO")
& T3 & T2 & T4 & T &".xls")
Dim Wd As MSExcel.Window =
Wb.Windows(1) '表示当前工作簿窗口
Wd.DisplayZeros = False '不显示0值
App.Visible = True
Wb.Save
End If
End If
这个代码是我的,打印的格式是XLS,是根据IO号打印到此文件夹中,自己修改一下.