以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 进图条显示完成进度百分比 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=108810) |
-- 作者:huhu -- 发布时间:2017/10/30 11:38:00 -- 进图条显示完成进度百分比 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("导出进度") |
-- 作者:有点甜 -- 发布时间:2017/10/30 11:58:00 -- For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据
pb.value = (r+1) / dt.rows.count * 100
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
|
-- 作者:huhu -- 发布时间:2017/11/1 18:35:00 -- 新的代码:进度条并未按照数值滚动。而是一下就结束了。当时我以为是数据少,后面弄了3K行数据,也是等很久最后一下就滚到最后了 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 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 msgbox(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)
|
-- 作者:有点甜 -- 发布时间:2017/11/1 19:33:00 -- Dim rkqssj As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
msgbox("现在开始")
|