通过正常的html链接打开excel文件 [英] Open excel file through normal html link

查看:1052
本文介绍了通过正常的html链接打开excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前遇到一个问题,我想在我们的Intranet中链接到一个共享excel表。
不幸的是,正常的 href =http:...链接会自动打开并将其保存到本地机器,而不是在共享页面上启用工作在服务器本身。

i am currently encountering an issue where I'd like to put a link to a shared excel sheet in our intranet. Unfortunately the normal href="http:..." link automatically opens and saves it to the local machine instead of enabling the work on the shared sheet which is on the server itself.

我已经阅读了这里,找到一些解决方案,如: file:///// SERVER / PATH / Excel .xls
但是可惜的是解决方案没有做任何事情。

I have read through here a bit and found solutions like : file://///SERVER/PATH/Excel.xls but sadly that solution doesn't do anything.

如果相关:我的服务器版本是Windows Server 2012

If its relevant: my server version is Windows Server 2012

推荐答案

HTTP是一种无状态协议。这对您来说意味着当您的用户通过http从内部网下载文件时,他们正在下载副本,而不是原始文件。它们所做的任何更改只会出现在其副本中,然后最终会导致不同的可能重叠更改的相同工作簿的副本的负载。你不想要这个!

HTTP is a stateless protocol. What that means for you is that when your users download a file from the intranet via http, they are downloading a copy, rather than the original. Any changes they make will only appear in their copy, and then you end up with loads of copies of the same workbook with different, possibly overlapping changes. You don't want that!

还有...你的用户甚至会上传他们的更改?

And also ... how are your users even going to upload their changes?

您需要在网络上创建共享文件夹,并将工作簿放在那里。然后,您可以在< a /> 文件:///SERVER/PATH/FILE.xls 格式c>您的Intranet上的链接,以将用户指向服务器上的实际文件。

You need to create a shared folder on your network and put the workbook there. You can then use the file:///SERVER/PATH/FILE.xls format in your <a /> links on your intranet to direct your user to the actual file on the server.

我建议您从在桌面上创建一个简单的html文档,以便熟悉文件:/// 路径格式。
例如

I would recommend you start by creating a simple html doc on your desktop to get familiar with the file:/// path format. Eg

<html>
    <head />
    <body>
        <a href="file:///SERVER/PATH/FILE.xls">Click</a>
    <body>
 <html>

保存在记事本中,并从 .txt .html

save that in notepad and rename the extension from .txt to .html.

您还可以键入 file:/// 路径直接进入Windows资源管理器的地址栏,允许测试路径而不诉诸上述html文档。

You can also type file:/// paths straight into windows explorer's address bar which allow for testing paths without resorting to the html document mentioned above.

UNFORTUNATELY !看来,浏览器的默认行为是总是下载一个链接而不是打开它(即使它是一个本地资源),所以如果你真的想打开它,那么你必须诉诸于更改浏览器的内部网络权限,以允许JS访问本地资源,然后允许您使用以下技术。

UNFORTUNATELY! It seems that the browsers default behavior is to always download a link rather than open it (even if it is a local resource), so if you actually want to open it then you must resort to changing your browser intranet permissions to allow JS to access local resources, which then allows you to use the technique below.

本文( http://www.codeproject.com/Articles/113678/How -to-execute-a-Local-File-using-HTML-Application )使用

<script type="text/javascript" language="javascript">
    function RunFile() {
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run("c:/windows/system32/notepad.exe", 1, false);
    }
</script>

打开记事本。您可以使用Excel.exe的命令行参数( https://support.office.com/en-za/article/Command-line-switches-for-Excel-321cf55a-ace4-40b3-9082-53bd4bc10725 )告诉文件路径是什么...

to open notepad. You can use command line arguments with Excel.exe (https://support.office.com/en-za/article/Command-line-switches-for-Excel-321cf55a-ace4-40b3-9082-53bd4bc10725) to tell it what the file path is...

Excel.exe "C:\PATH\Excel.xls"

这篇关于通过正常的html链接打开excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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