以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  导入项目下所有工作表出现错误,请指正  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=18091)

--  作者:狐狸爸爸
--  发布时间:2012/4/1 17:59:00
--  
你删除这个三个excel文件的sheet2和sheet3,就正常了,这些是空表。
--  作者:狐狸爸爸
--  发布时间:2012/4/2 8:55:00
--  
因为你全部要导入到同一个项目文件,而同一个项目,是不允许存在同名的表的。
--  作者:狐狸爸爸
--  发布时间:2012/4/5 11:55:00
--  
Dim file As String
Dim dd,i,p,b As Integer
For Each File In FileSys.GetFiles(ProjectPath)
    If file.EndsWith(".xls") Then
        Dim Book1 As New XLS.Book(file)
        dd = Book1.Sheets.count
        For i = 0 To dd - 1
            Dim ip As New Importer
            ip.SourcePath =file  \'指定数据文件
            Dim Sheet As XLS.Sheet = Book1.Sheets(i)
            ip.SourceTableName =sheet.name \'指定要导入的表
            p=file.LastIndexOf("\\")+1
            b=file.length-4
            ip.NewTableName =file.substring(p,b-p) & "_" & sheet.name
            ip.Format = "Excel" \'指定导入格式
            ip.Import()
        Next
    End If
Next