Dim rkqssj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim rkjzsj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim pb As WinForm.ProgressBar = e.Form.Controls("ProgressBar1")
DataTables("库存明细表").LoadFilter = "入库完成时间 > = '" & rkqssj.value & "' and 入库完成时间 < = '" & rkjzsj.value.AddDays(1) & "' and 状态 = '入库完成'"
DataTables("库存明细表").Load
msgbox("现在开始")
Dim dt As Table = Tables("库存明细表")
Dim filepath As String = "C:\库存明细表\在库\" & rkqssj.value & "-" & rkjzsj.value & ".xls"
Dim nms() As String = {"SN","MAC","HW","库位类别","生产订单号码","工单行号","订单号","订单行号","物料编码","物料名称","博达物料编码","软件版本","入库完成时间"} '要导出的列名
Dim caps() As String = {"SN","MAC","HW","库位类别","生产订单号码","工单行号","订单号","订单行号","物料编码","物料名称","博达物料名称","软件版本","入库完成时间"} '对应的列标题
Dim szs() As Integer = {120,200,200,80,200,80,100,80,100,150,100,100,150} '对应的列宽
Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim st1 As XLS.Style = Book.NewStyle '日期列的显示格式
st1.Format = "yyyy-MM-dd"
For c As Integer = 0 To nms.length -1
Sheet(0, c).Value = caps(c) '指定列标题
Sheet.Cols(c).Width = szs(c) '指定列宽
If dt.Cols(nms(c)).IsDate Then '如果是日期列
Sheet.Cols(c).Style = st1 '设置显示格式
End If
Next
For r As Integer = 0 To dt.Rows.Count - 1 '填入数据
pb.value = (r+1) / dt.rows.count * 100
application.doevents
output.show(pb.value)
For c As Integer = 0 To nms.length -1
If not dt.rows(r).Isnull(nms(c)) Then Sheet(r +1, c).Value = dt.rows(r)(nms(c))
Next
Next
Book.Save(filepath)
MessageBox.show("保存路径:" & FilePath,"导出成功",MessageBoxButtons.OK,MessageBoxIcon.Information)