Foxtable(狐表)用户栏目专家坐堂 → 请教一个日期时间的导入问题!


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

主题:请教一个日期时间的导入问题!

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/3/20 16:04:00 [显示全部帖子]

 foxtable去excel时间是有问题的,要用vba去处理才行

 

 Dim dlg As New OpenFileDialog
dlg.Filter= "所有文件|*.*|Excel2003文件|*.xls|Excel2007文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
   
    MessageBox.Show("你选择的是:" & dlg.FileName,"提示")
    If MessageBox.Show("是否合并?","请确 认!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) = DialogResult.OK Then
        DataTables("表A").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 = 2 To rg.Rows.Count
                Dim ro As Row = Tables("表A").AddNew
                For i As Integer = 0 To Tables("表A").Cols.Count - 1
                    ro(i) = ws.Cells(n,i+2).Text
                Next
            Next
        catch ex As exception
            msgbox(ex.message)
        finally
            DataTables("表A").ResumeRedraw
            app.quit
        End try
       
    Else
        Return
    End If
End If
MessageBox.Show("导入成功!","恭喜!")


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2015/3/20 16:45:00 [显示全部帖子]

换一下,用二维数组导入会快

 

Dim dlg As New OpenFileDialog
dlg.Filter= "所有文件|*.*|Excel2003文件|*.xls|Excel2007文件|*.xlsx" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then '如果用户单击了确定按钮
   
    MessageBox.Show("你选择的是:" & dlg.FileName,"提示")
    If MessageBox.Show("是否合并?","请确 认!",MessageBoxButtons.OKCancel,MessageBoxIcon.Question) = DialogResult.OK Then
        DataTables("表A").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
            Dim ary = rg.value
            For n As Integer = 2 To rg.Rows.Count
                Dim ro As Row = Tables("表A").AddNew
                For i As Integer = 0 To Tables("表A").Cols.Count - 1
                    ro(i) = ary(n,i+2)
                Next
            Next
            MessageBox.Show("导入成功!","恭喜!")
        catch ex As exception
            msgbox(ex.message)
            MessageBox.Show("导入失败!","恭喜!")
        finally
            DataTables("表A").ResumeRedraw
            app.quit
        End try
       
    Else
        Return
    End If
End If


 回到顶部