Foxtable(狐表)用户栏目专家坐堂 → 求助,这种Excel数据导入代码怎么写?


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

主题:求助,这种Excel数据导入代码怎么写?

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


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

Dim dlg As new OpenFileDialog
dlg.Filter = "Excel|*.xls"
If dlg.ShowDialog = DialogResult.OK Then
    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
        Dim nms() As String = {"", "招标人代理机构代码", "项目经办人","标段编号", "标段名称", "", "开标日期"}
        DataTables("表A").StopRedraw
        For n As Integer = 3 To rg.Rows.Count
            Dim ro As Row = Tables("表A").AddNew
            For i As Integer = 0 To nms.length - 1
                If nms(i)>"" Then
                    If ary(n,i+1) <> Nothing Then
                        ro(nms(i)) = cstr(ary(n,i+1)).trim
                    ElseIf n > 3 AndAlso ary(n-1,i) <> Nothing Then
                        ro(nms(i)) = cstr(ary(n-1,i+1)).trim
                    End If
                End If
            Next
        Next
        MessageBox.Show("导入成功!","恭喜!")
    catch ex As exception
        msgbox(ex.message)
        MessageBox.Show("导入失败!","恭喜!")
    finally
        DataTables("表A").ResumeRedraw
        app.quit
    End try
End If

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


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

以下是引用lyb在2017/10/19 10:51:00的发言:
数据没有合并,但可以导入了,消化一下,谢谢甜版!

 

如果要合并,参考

 

http://www.foxtable.com/webhelp/scr/1373.htm

 

 


 回到顶部