以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 导入电子表格出错 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=154535) |
-- 作者:fntfgz -- 发布时间:2020/9/17 16:57:00 -- 导入电子表格出错 老师,我想把一个文件夹下的电子表格都导入到一个表中,导到一半出现错误,请老师看看是啥问题引起的 Dim nms() As String = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n"} Dim bm As String="数据导入" For Each file As String In FileSys.GetFiles("F:\\邮箱下载\\0917培训名单") If file.EndsWith(".xls") OrElse file.EndsWith(".xlsx") Then output.show(file) Dim Book As New XLS.Book(file) Dim Sheet As XLS.Sheet = Book.Sheets(0) Tables(bm).StopRedraw() \'\'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致 \'\'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题 For n As Integer = 0 To Sheet.Rows.Count -1 Dim r As Row = Tables(bm).AddNew() For m As Integer = 0 To nms.Length - 1 r(nms(m)) = Sheet(n,m).Value Next Next Tables(bm).ResumeRedraw() End If Next |
-- 作者:有点蓝 -- 发布时间:2020/9/17 17:13:00 -- 可能有些文件没有表格 output.show(file) Dim Book As New XLS.Book(file) output.show(Book.Sheets.count)
Dim Sheet As XLS.Sheet = Book.Sheets(0) |