Foxtable(狐表)用户栏目专家坐堂 → 如何提取目录下的文件到EXCEL报表


  共有3781人关注过本帖平板打印复制链接

主题:如何提取目录下的文件到EXCEL报表

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


加好友 发短信
等级:小狐 帖子:392 积分:3312 威望:0 精华:0 注册:2014/4/9 10:04:00
  发帖心情 Post By:2015/5/14 16:56:00 [只看该作者]

以下代码只能提取指定目录下的文件名,为什么不能提取其子目录下的文件名?代码哪有问题?

 

’提取文件按钮事件

 

Dim FilePath As WinForm.TextBox = e.Form.Controls("TextBox1")

If FileSys.DirectoryExists(FilePath.Value) Then
    Functions.Execute("文件名提取函数",FilePath.value)
End If

 

‘自定义函数

Dim path As String = args(0)

Dim Book As New XLS.Book '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Sheet(0, 0).Value = "文件名"
Dim r As Integer = 1
For Each file As String In FileSys.GetFiles(path)
    Dim Ifo As new FileInfo(file)
    If Ifo.hidden=False Then
        sheet(r,0).value = filesys.getname(file)
        r += 1
    End If
Next

For Each p As String In FileSys.GetDirectories(path)
    Functions.Execute("文件名提取函数",p)
Next
Book.Save("c:\reports\test.xls")


 回到顶部
总数 20 1 2 下一页