Dim ST As Date
Dim ET As Date
Dim EET As Date
ST = RibbonTabs("博达仓库明细系统").Groups("入库时间").Items("ST").value
ET = RibbonTabs("博达仓库明细系统").Groups("入库时间").Items("ET").value
EET = ET.AddDays(1)
DataTables("库存明细表").LoadFilter = "入库完成时间 > = '" & ST & "' and 入库完成时间 < = '" & EET & "' and 状态 = '入库完成'"
DataTables("库存明细表").Load
Dim dt As Table = Tables("库存明细表")
Dim filepath As String = "C:\库存明细表\" & ST & "-" & ET & ".xls"
Dim nms() As String = {"SN","MAC","HW","库位类别","生产订单号码","工单行号","订单号","订单行号","物料编码","物料名称","博达物料编码","软件版本","BD出库单号","U8出库单号","U8发货单号","货运单号","发货地址","业务员","入库完成时间","出库完成时间"} '要导出的列名
Dim caps() As String = {"SN","MAC","HW","库位类别","生产订单号码","工单行号","订单号","订单行号","物料编码","物料名称","博达物料名称","软件版本","BD出库单号","U8出库单号","U8发货单号","货运单号","发货地址","业务员","入库完成时间","出库完成时间"} '对应的列标题
Dim szs() As Integer = {80,200,200,80,200,80,100,80,100,150,100,100,100,100,100,100,100,100,150,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 '填入数据
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)
从这段代码开始执行到完成,希望有一个进度条显示进度百分比。
Dim vl As Double
Dim pb As RibbonMenu.ProgressBar
pb = RibbonTabs("博达仓库明细系统").Groups("状态").Items("导出进度")