如何使用ASP .NET C在浏览器中打开开放式办公室电子表格文档# [英] How to open open office spread sheet document in browser using ASP .NET C#

查看:147
本文介绍了如何使用ASP .NET C在浏览器中打开开放式办公室电子表格文档#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Below is my code which opens a word or spread sheet document when user clicks the image in browser.But i need to open that word/spread sheet document in the browser itself.How can i do this 





我尝试了什么:



i尝试上面的代码,但它没有工作



What I have tried:

i tried above code but its not working

推荐答案

你不能强迫自己的方式。决定是针对最终用户的,因为这是他的电脑...

您必须考虑几个问题:

1.用户可能没有可以打开请求的应用程序文件类型

2.即使用户有这样的应用程序,该应用程序可能无法与浏览器一起播放,所以无论如何都无法在浏览器内打开文档...

3.即使在最舒适的设置中,用户也可以决定他希望下载和不显示文件,或者在任何情况下在浏览器外面打开...



无论如何,不​​应该关注最终用户如何收到文件 - 只需提供它......



但是!如果你有像我这样的客户(PITA)......你必须自己编写(借用)一些浏览器或让他们为浏览器安装一些扩展(取决于浏览器)......
You can not force your way. The decision is for the end user as this is his computer...
You have to consider several issues:
1. User may has not application that can open the requested document type
2. Even user has such application, that application may not play well with the browser, so no way to open the document inside the browser anyway...
3. Even in the most comfortable setup, user can decide that he wants the files to be downloaded and not displayed, or opened outside the browser in any case...

In any case it should not be your concern how the end user receives the file - simply supply it...

BUT! If you have customers like mine (PITA)... You have to write (borrow) some viewer of your own or let them install some extensions for the browser (depends on the browser)...


您的.net代码正在服务器上运行,因此您正在服务器上启动该进程,以便在服务器上启动该文件。您的.net代码未在浏览器内或客户端计算机上运行。这个代码在开发网站时起作用,因为服务器和客户端是同一台机器,但是当你在远程服务器上它将停止工作。



谷歌asp.net发送文件到客户端,你会找到一些正确的代码。如果MIME类型对于文件是正确的,那么文件将在浏览器中打开的机会最大,但正如解决方案1中所述,它取决于各种事情,没有办法强制文件在浏览器中打开。
Your .net code is running on the server so you're starting the process on the server so the file is being launched on the server. Your .net code isn't running inside the browser or on the client machine. This code will have worked when developing the site as the server and client are the same machine, but when you are on a remote server it is going to stop working.

Google for "asp.net send file to client" and you'll find some proper code. If the MIME type is correct for the file it gives the best chance the file will open in the browser, but as said in Solution 1 it depends on various things, there is no way to force the file to open in the browser.


Quote:

如何使用ASP .NET C#在浏览器中打开开放式办公室电子表格文件#

How to open open office spread sheet document in browser using ASP .NET C#

简短的回答:你没有。

浏览器无法在客户端启动任意应用程序,这是一项安全功能。

浏览器唯一可以做的事情是使用pdf阅读器等插件注册的启动应用程序,或者如果您下载文件并允许应用程序启动,但它意味着用户验证。

Short answer: you don't.
The browser can't launch arbitrary app on client side, it is a security feature.
The only thing that the browser can do is launch apps registered with a plugin like pdf reader or if you download a file and allow app launch, but it imply user validation.


这篇关于如何使用ASP .NET C在浏览器中打开开放式办公室电子表格文档#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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