Foxtable(狐表)用户栏目专家坐堂 → [求助]小白求教,excel导如 foxtable里,格式不对求教!


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

主题:[求助]小白求教,excel导如 foxtable里,格式不对求教!

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/6 11:29:00 [显示全部帖子]


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/6 15:13: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("sheet2").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("sheet2").AddNew
                For i As Integer = 0 To Tables("sheet2").Cols.Count - 1
                    ro(i) = ws.Cells(n,i+1).Text
                Next
            Next
            MessageBox.Show("导入成功!","恭喜!")
        catch ex As exception
            msgbox(ex.message)
            MessageBox.Show("导入失败!","恭喜!")
        finally
            DataTables("sheet2").ResumeRedraw
            app.quit
        End try
       
    Else
        Return
    End If
End If


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/5/7 9:35: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("sheet2").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 cs() As String = {"起始时间", "落地时间"}
            For n As Integer = 2 To rg.Rows.Count
                Dim ro As Row = Tables("sheet2").AddNew
                For i As Integer = 0 To cs.length - 1
                    ro(cs(i)) = ws.Cells(n,i+1).Text
                Next
            Next
            MessageBox.Show("导入成功!","恭喜!")
        catch ex As exception
            msgbox(ex.message)
            MessageBox.Show("导入失败!","恭喜!")
        finally
            DataTables("sheet2").ResumeRedraw
            app.quit
        End try
       
    Else
        'Return
    End If
End If


 回到顶部