如何使用WebBrowser(vb)来显示各种文件? [英] How to use WebBrowser (vb) to show various kinds of file?

查看:149
本文介绍了如何使用WebBrowser(vb)来显示各种文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在

屏幕上编写一个显示文件(xls,doc,html,pdf,jpg)的程序。我以为我可以在VB2005中使用WebBrowser来完成这项工作,因为那些

种类的文件都可以在IE中显示。


我尝试使用下面的代码,但失败:

Dim fs As FileStream

fs = File.OpenRead(" D:\ dococ \ joblist.xls")

WebBrowserMsg.DocumentStream = fs

==>显示二进制数据,而不是Excel数据


我也试试:

WebBrowserMsg.Url = New Uri(" d:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ (怎么去

SUPRESS它打开alwasys)?

==使用这种方法是对的吗?


谢谢提前。

Benson。


I want to write a program to display files (xls, doc,html,pdf,jpg) on
screen. I thought I can use WebBrowser in VB2005 to do this job since those
kinds of files can be displayed in IE.

I try to use the following code, but FAIL:
Dim fs As FileStream
fs = File.OpenRead("D:\doc\joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>show binary data, not Excel data

I also try:
WebBrowserMsg.Url = New Uri("d:\doc\joblist.xls")
==seems to work, but with a "save or open dialog box shown" (HOW TO
SUPRESS IT to alwasys open)?
==Is it right to use this method??

Thanks advance.
Benson.


推荐答案

我想大多数人都使用Process.Start和传入文件名,并且

Windows计算出用于打开文件的程序。你试过

吗?


Robin S.

-------------- ----------------------------

" Benson" < be ******* @ yahoo.com.hkwrote in message

news:eH ************** @ TK2MSFTNGP02.phx.gbl。 ..
I think most people use Process.Start and pass in the file name, and
Windows figures out what program to use to open the file. Have you tried
that?

Robin S.
------------------------------------------
"Benson" <be*******@yahoo.com.hkwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...

>我想编写一个程序来在
屏幕上显示文件(xls,doc,html,pdf,jpg)。我以为我可以在VB2005中使用WebBrowser来完成这项工作,因为这些类型的文件可以在IE中显示。


我尝试使用以下代码,但是失败:

Dim fs As FileStream

fs = File.OpenRead(" D:\doc \ joblist.xls")

WebBrowserMsg。 DocumentStream = fs

==>显示二进制数据,而不是Excel数据


我也尝试:

WebBrowserMsg.Url =新的Uri(d:\ doc \ joblist.xls)

==似乎有效,但是显示的是保存或打开的对话框。 (怎么去

SUPRESS它打开alwasys)?

==使用这种方法是对的吗?


谢谢提前。

Benson。

>I want to write a program to display files (xls, doc,html,pdf,jpg) on
screen. I thought I can use WebBrowser in VB2005 to do this job since
those kinds of files can be displayed in IE.

I try to use the following code, but FAIL:
Dim fs As FileStream
fs = File.OpenRead("D:\doc\joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>show binary data, not Excel data

I also try:
WebBrowserMsg.Url = New Uri("d:\doc\joblist.xls")
==seems to work, but with a "save or open dialog box shown" (HOW TO
SUPRESS IT to alwasys open)?
==Is it right to use this method??

Thanks advance.
Benson.



是的。我知道这个功能,我认为它应该有效。但我希望我的

应用程序具有以下附加功能:

1.在我的应用程序中打开文件,例如。在一个面板内

2.希望用户不需要安装任何Excel,Word或pdf程序来查看我的应用程序中的
这样的文件。


还有什么建议吗?如果不是,我会使用Robin的建议。

谢谢。

Benson。


" RobinS" ?<滚装**** @ NoSpam.yah.none×??? I A] tD型???:博********************** ********@comcast.co m ...
Yes. I know this function and I think it should work. But I hope my
application has the following addition features:
1. Open the file inside my application eg. inside a panel
2. Hope user need not install any Excel, Word or pdf programs for viewing
such files inside my application.

Any further suggestion? If no, I use what Robin has suggested.
Thanks.
Benson.

"RobinS" <Ro****@NoSpam.yah.none×???ì?à]?tD???:Bo******************************@comcast.co m...

>我想大多数人都使用Process.Start并传入文件名,
Windows计算出用于打开文件的程序。你试过那个吗?


Robin S.

------------------ ------------------------

" Benson" < be ******* @ yahoo.com.hkwrote in message

news:eH ************** @ TK2MSFTNGP02.phx.gbl。 ..
>I think most people use Process.Start and pass in the file name, and
Windows figures out what program to use to open the file. Have you tried
that?

Robin S.
------------------------------------------
"Benson" <be*******@yahoo.com.hkwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...

>>我想编写一个程序来在
屏幕上显示文件(xls,doc,html,pdf,jpg)。我以为我可以在VB2005中使用WebBrowser来完成这项工作,因为这些类型的文件可以在IE中显示。

我尝试使用以下代码,但是失败:
Dim fs As FileStream
fs = File.OpenRead(" D:\doc \ joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>显示二进制数据,而不是Excel数据

我也尝试:
WebBrowserMsg.Url = New Uri(" d:\\\\\\\\\\\\\\\\\\\ = =)==似乎有效,但是使用显示的保存或打开对话框 (如何打开它让alwasys打开)?
==使用这种方法是对的吗?

谢谢提前。
Benson。

>>I want to write a program to display files (xls, doc,html,pdf,jpg) on
screen. I thought I can use WebBrowser in VB2005 to do this job since
those kinds of files can be displayed in IE.

I try to use the following code, but FAIL:
Dim fs As FileStream
fs = File.OpenRead("D:\doc\joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>show binary data, not Excel data

I also try:
WebBrowserMsg.Url = New Uri("d:\doc\joblist.xls")
==seems to work, but with a "save or open dialog box shown" (HOW TO
SUPRESS IT to alwasys open)?
==Is it right to use this method??

Thanks advance.
Benson.




我不认为你可以查看没有这些程序的Excel或Word文件
已安装
,除非有可用的查看器且已安装。 (我知道

有一个用于Excel,但我不知道Word。)我不确定你是否可以

甚至打开Office文件在IE中,除非你有Office软件。


至于pdf,你只需要Acrobat,它是免费的,大多数人都有。


祝你好运;让我知道它是怎么回事。

Robin S.

------------------------ ------------

" Benson" < be ******* @ yahoo.com.hkwrote in message

news:O9 ************** @ TK2MSFTNGP04.phx.gbl。 ..
I don''t think you can view Excel or Word files w/o having those programs
installed, unless there is a viewer available and it''s installed. (I know
there''s one for Excel, but I don''t know about Word.) I''m not sure you can
even open Office files in IE unless you have the Office software.

As for pdf, you just need Acrobat, and it''s free and most people have that.

Good luck; let me know how it goes.
Robin S.
------------------------------------
"Benson" <be*******@yahoo.com.hkwrote in message
news:O9**************@TK2MSFTNGP04.phx.gbl...

是的。我知道这个功能,我认为它应该有效。但我希望我的

应用程序具有以下附加功能:

1.在我的应用程序中打开文件,例如。在一个面板内

2.希望用户不需要安装任何Excel,Word或pdf程序来查看我的应用程序中的
这样的文件。


还有什么建议吗?如果不是,我会使用Robin的建议。

谢谢。

Benson。


" RobinS" ?<滚装**** @ NoSpam.yah.none×??? I A] tD型???:博********************** ********@comcast.co m ...
Yes. I know this function and I think it should work. But I hope my
application has the following addition features:
1. Open the file inside my application eg. inside a panel
2. Hope user need not install any Excel, Word or pdf programs for viewing
such files inside my application.

Any further suggestion? If no, I use what Robin has suggested.
Thanks.
Benson.

"RobinS" <Ro****@NoSpam.yah.none×???ì?à]?tD???:Bo******************************@comcast.co m...

>>我想大多数人都使用Process.Start并传入文件名,和
Windows计算出用于打开文件的程序。你试过那个吗?

Robin S.
-------------------------- ----------------
Benson < be ******* @ yahoo.com.hkwrote in message
新闻:eH ************** @ TK2MSFTNGP02.phx.gbl ...
>>I think most people use Process.Start and pass in the file name, and
Windows figures out what program to use to open the file. Have you tried
that?

Robin S.
------------------------------------------
"Benson" <be*******@yahoo.com.hkwrote in message
news:eH**************@TK2MSFTNGP02.phx.gbl...

>>>我想编写一个程序来在
屏幕上显示文件(xls,doc,html,pdf,jpg)。我以为我可以在VB2005中使用WebBrowser来完成这项工作,因为这些类型的文件可以在IE中显示。

我尝试使用以下代码,但是失败:
Dim fs As FileStream
fs = File.OpenRead(" D:\doc \ joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>显示二进制数据,而不是Excel数据

我也尝试:
WebBrowserMsg.Url = New Uri(" d:\\\\\\\\\\\\\\\\\\\ = =)==似乎有效,但是使用显示的保存或打开对话框 (如何打开它让alwasys打开)?
==使用这种方法是对的吗?

谢谢提前。
Benson。

>>>I want to write a program to display files (xls, doc,html,pdf,jpg) on
screen. I thought I can use WebBrowser in VB2005 to do this job since
those kinds of files can be displayed in IE.

I try to use the following code, but FAIL:
Dim fs As FileStream
fs = File.OpenRead("D:\doc\joblist.xls")
WebBrowserMsg.DocumentStream = fs
==>show binary data, not Excel data

I also try:
WebBrowserMsg.Url = New Uri("d:\doc\joblist.xls")
==seems to work, but with a "save or open dialog box shown" (HOW TO
SUPRESS IT to alwasys open)?
==Is it right to use this method??

Thanks advance.
Benson.





这篇关于如何使用WebBrowser(vb)来显示各种文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆