Dim webCtl As WinForm.WebBrowser = e.Form.Controls("WebBrowser1")
Dim webb = webCtl.BaseControl
'webb.ScrollBarsEnabled = False '禁止滚动条
webb.ScriptErrorsSuppressed = True '禁止js错误提示
webb.IsWebBrowserContextMenuEnabled = False '禁止快捷菜单
webb.WebBrowserShortcutsEnabled = False '禁止快捷键
''''''禁用鼠标右键
If Tables("主窗口_table1").Current IsNot Nothing Then
Dim ftp1 As new ftpclient
Tables("FTP配置信息").Position =0 '移动到第一行,以免出错
ftp1.Host=trim(Tables("FTP配置信息").current("地址"))
ftp1.Account = trim(Tables("FTP配置信息").current("账号"))
ftp1.password = trim(Tables("FTP配置信息").current("密码"))
Dim lj As String = Tables("主窗口_table1").Current("路径")
Dim fp As String = lj
Dim wjm As String = Tables("主窗口_table1").Current("文件名")
Dim hz As String = Tables("主窗口_table1").current("后缀")
If ftp1.Download(fp,projectpath & "RemoteFiles\" & wjm) = True Then
If hz = "doc" Or hz = "docx" Then
Dim tmp As String = projectpath & "RemoteFiles\" & wjm '''下载的文件路径
Dim mht As String = projectpath & "RemoteFiles\" & wjm & ".mhtml" ''''转换为MHTML格式的文件路径
Dim doc As New Spire.Doc.Document
doc.LoadFromFile(tmp)
'保存为Png格式的图片
Dim images() As Image = doc.SaveToImages(Spire.Doc.Documents.ImageType.Metafile)
Dim i As Integer = 0
Do While (i < images.Length)
Dim outputfile As String = String.Format(projectpath & "RemoteFiles\" & "image-{0}.png", i)
images(i).Save(outputfile, System.Drawing.Imaging.ImageFormat.Png)
i = (i + 1)
Loop
''''''==========
vars("p") = 0
Dim s As String = projectpath & "RemoteFiles\" & "image-" & vars("p") & ".png "
e.Form.Controls("WebBrowser1").Address = s '''''为打开生成的照片
'''''===============================打开word
ElseIf hz = "xls" Or hz = "xlsx" Then
Dim tmp As String = projectpath & "RemoteFiles\" & wjm
Dim mht As String = projectpath & "RemoteFiles\" & wjm & ".mhtml"
Dim rpt As New XLS.Book(tmp)
rpt.Build()
'rpt.Sheets(0).Rows(0).Visible = False '隐藏第一个空行
rpt.SaveToMHT(mht)
e.Form.Controls("WebBrowser1").Address = mht
''''===============================打开excel
ElseIf hz = "PDF" Or hz = "jpg" Or hz = "png" Or hz = "gif" Or hz = "bmp" Or hz = "jpeg"
Dim tmp As String = projectpath & "RemoteFiles\" & wjm
e.Form.Controls("WebBrowser1").Address = tmp
''''=============================打开PDF,照片
Else
Messagebox.show("暂不支持该格式文件,请下载到本地打开!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
Else
e.Form.text = "浏览器 打开失败...."
End If
End If
我打开的是excel文件,后缀是xls