Foxtable(狐表)用户栏目专家坐堂 → 提取excel文件的问题


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

主题:提取excel文件的问题

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


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

贴出所写代码。

[此贴子已经被作者于2018/5/21 17:13:05编辑过]

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


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

Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
    For Each fl As String In dlg.FileNames
        Dim Book As new XLS.Book(fl)
        If book.sheets.Count <= 5 Then
            msgbox("sheet小于6个,不能导入")
        Else
            Dim Sheet As XLS.Sheet = Book.Sheets(5) '也可以写sheet的名字的
            Dim s As String
            s = filesys.GetName(fl)
            Dim t = s.Substring(4)
            Tables("AC01").StopRedraw()
            Dim nms() As String = {"月度","区域","渠道","品牌","年","大类","库龄","跌价"}
            For n As Integer = 1 To Sheet.Rows.Count -1
                Dim r As Row = Tables("AC01").AddNew()
                r(nms(0)) = t
                For m As Integer = 1 To nms.Length
                    r(nms(m)) = Sheet(n,m-1).Value
                Next
            Next
        End If
    Next
End If

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


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

Dim dlg As New OpenFileDialog
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
    For Each fl As String In dlg.FileNames
        Dim Book As new XLS.Book(fl)
        If book.sheets.Count <= 5 Then
            msgbox("sheet小于6个,不能导入")
        Else
            Dim Sheet As XLS.Sheet = Book.Sheets(5) '也可以写sheet的名字的
            Dim s As String
            s = filesys.GetName(fl)
            Dim t = s.Substring(4)
            Tables("AC01").ResumeRedraw
            Tables("AC01").StopRedraw()
            Dim nms() As String = {"月度","区域","渠道","品牌","年","大类","库龄","跌价"}
            For n As Integer = 1 To Sheet.Rows.Count -1
                Dim r As Row = Tables("AC01").AddNew()
                r(nms(0)) = t
                For m As Integer = 1 To nms.Length-1
                    r(nms(m)) = Sheet(n,m-1).Value
                Next
            Next
           
            Tables("AC01").ResumeRedraw
        End If
    Next
End If


 回到顶部