Foxtable(狐表)用户栏目专家坐堂 → [求助]选择EXCEL,当有密码时出错


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

主题:[求助]选择EXCEL,当有密码时出错

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


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

加入 try catch

 

Dim dlg As New OpenFileDialog
dlg.Filter= "Excel 97-2003文件(*.xls)|*.xls|Excel 2007文件(*.xlsx)|*.xlsx"
If dlg.ShowDialog = DialogResult.Ok Then
    Dim cmb1 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
    Dim txtb1 As WinForm.TextBox = e.Form.Controls("TextBox1")
    txtb1.value = dlg.FileName
    cmb1.Value = ""
    If txtb1.Value > "" Then
        try
            Book = New XLS.Book(txtb1.value)
            cmb1.items.clear
            Dim str(Book.Sheets.count - 1) As String
            Dim Sheet As XLS.Sheet
            For i As Integer = 0 To Book.Sheets.count - 1
                str(i) = Book.Sheets(i).name ' str.add(Book.Sheets(i).name)
            Next
            cmb1.Items.AddRange(str)
        catch ex As exception
            msgbox("打开excel文件出错")
        End try
    End If
    cmb1.Select()
End If


 回到顶部