Foxtable(狐表)用户栏目专家坐堂 → [求助] 导入合并时间显示00:00


  共有2822人关注过本帖树形打印复制链接

主题:[求助] 导入合并时间显示00:00

帅哥哟,离线,有人找我吗?
wangyinming
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
[求助] 导入合并时间显示00:00  发帖心情 Post By:2015/6/13 22:44:00 [只看该作者]

用以下代码合并时,"开始时间","结束时间"显示00:00,但是在excel模板中都是时间格式了,请各位看看如何解决。

Dim pr As Integer = DataTables("检查").DataRows.Count     '查询表行数
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    Dim c As Integer = 0
    Dim Book As New XLS.Book(dlg.FileName)
    Dim Sheet As XLS.Sheet = Book.Sheets(0)
    Tables("检查").StopRedraw()
    '注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
    Dim nms() As String = { "编号","工程","班","作业日","正常时间","加班时间","工号","姓名","机台号码","型号","辅助编码","管理号码","管理号码1","管理号码2","生产数","良品","不良品","段取品","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","开始时间","结束时间","开动时间","连班时间","稼动时间","检查","切边","自动切边","空检","磁检","套弹簧","组装","防锈包装","称油脂","返工","不良调试","毛边确认","气泡确认","裂开确认","作业标准","能力","必要时间","生产效率","故障时间","材料时间","品检时间","异常时间","段取时间","调整时间","初品时间","其它时间" }
    '注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
    For n As Integer = 2 To Sheet.Rows.Count -1
        Dim bh As String = sheet(n,0).Text
        Dim dr As DataRow = DataTables("检查").Find("编号 = '" & bh & "'")
        If dr Is Nothing Then '如果不存在同编号的订单
            dr =  DataTables("检查").AddNew()
        End If
        For m As Integer = 0 To nms.Length - 1
            dr(nms(m)) = Sheet(n,m).Value
        Next
    Next
    Tables("检查").ResumeRedraw()
    'Dim i As Integer
    'For i  = DataTables("检查").DataRows.Count-1 To 0 Step -1
        'Dim dr As DataRow = DataTables("检查").DataRows(i)
        'Dim dr2 As DataRow = DataTables("检查").Find("管理号码='" & dr("管理号码") & "' and 良品='" & dr("良品") & "'and 管理号码1='" & dr("管理号码1") & "'and 工号='" & dr("工号") & "'  and _Identify <> " & dr("_Identify"))
        'If dr2 IsNot Nothing Then
            'dr2.Delete
        'End If
    'Next  '去重复值
    '
    'DataTables("检查").DeleteFor("[管理号码] is null or [良品] is null")  '删除空白行
    '
    pr = DataTables("检查").DataRows.Count - pr '查询表行数
    
    
    MessageBox.Show("成功导入数据"& pr &"条","提示")
End If
    
    
    Syscmd.Table.ToggleSortAndFilter()
    DataTables("检查").Save()

 回到顶部
帅哥哟,离线,有人找我吗?
wangyinming
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
  发帖心情 Post By:2015/6/13 23:26:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:catch.jpg
图片点击可在新窗口打开查看
模板时间格式设为是日期,使用系统导入命令显示正常。
但是使用我的代码,显示00:00
列格式TIME和date、DateLongTime  都试过了,无效,,,,求解··········

 回到顶部
帅哥哟,离线,有人找我吗?
wangyinming
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
  发帖心情 Post By:2015/6/13 23:27:00 [只看该作者]

大红袍老师在吗??
图片点击可在新窗口打开查看此主题相关图片如下:catch7c26.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2015/6/13 23:30:09编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
wangyinming
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
  发帖心情 Post By:2015/6/13 23:43:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:201501.xls

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table

 

特制作了列子,请大家确认


 回到顶部
帅哥哟,离线,有人找我吗?
wangyinming
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
  发帖心情 Post By:2015/6/14 7:59:00 [只看该作者]

自己顶一下吧,求解决

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/14 9:37:00 [只看该作者]


 回到顶部
客人(117.85.*.*)
  7楼


  发帖心情 Post By:2015/6/14 23:16:00 [只看该作者]

求代码,不知道2个代码链接在一起。


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/6/15 9:19:00 [只看该作者]

Dim pr As Integer = DataTables("检查").DataRows.Count     '查询表行数
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
    '注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
    Dim nms() As String = { "编号","工程","班","作业日","正常时间","加班时间","工号","姓名","机台号码","型号","辅助编码","管理号码","管理号码1","管理号码2","生产数","良品","不良品","段取品","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","开始时间","结束时间","开动时间","连班时间","稼动时间","检查","切边","自动切边","空检","磁检","套弹簧","组装","防锈包装","称油脂","返工","不良调试","毛边确认","气泡确认","裂开确认","作业标准","能力","必要时间","生产效率","故障时间","材料时间","品检时间","异常时间","段取时间","调整时间","初品时间","其它时间" }
    Tables("检查").ResumeRedraw()
    Tables("检查").StopRedraw()
    Dim App As New MSExcel.Application
    try
        Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.FileName)
        Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
        Dim Rg As MSExcel.Range = Ws.UsedRange
        For n As Integer = 3 To rg.Rows.Count
            Dim bh As String = ws.Cells(n,1).Text
            Dim dr As DataRow = DataTables("检查").Find("编号 = '" & bh & "'")
            If dr Is Nothing Then '如果不存在同编号的订单
                dr =  DataTables("检查").AddNew()
            End If
            For m As Integer = 0 To nms.Length - 1
                dr(nms(m)) = ws.Cells(n,m+1).Value
            Next
           
        Next
    catch ex As exception
        msgbox(ex.message)
    finally
        Tables("检查").ResumeRedraw()
        app.quit
    End try
   
    Tables("检查").ResumeRedraw()
    pr = DataTables("检查").DataRows.Count - pr '查询表行数
    MessageBox.Show("成功导入数据"& pr &"条","提示")
End If


Syscmd.Table.ToggleSortAndFilter()
DataTables("检查").Save()

 


 回到顶部