如何在Excel应用程序中使用javascript打开excel html文件 [英] How to use javascript to open excel html file in excel application

查看:118
本文介绍了如何在Excel应用程序中使用javascript打开excel html文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript或jQuery在Excel中从浏览器打开excel html文件?



我一直试图使用window.open(href )打开一个html excel文件。它在服务器上的位置是:/server/excelfiles/myexcel.xls,我试图在Excel应用程序中打开它,而不是在IE浏览器中的活动x控件中。它甚至有可能在应用程序中而不是浏览器中打开一个文件?

解决方案

两种方法:

b
$ b

 < a href =/ server / excelfiles / myexcel.xlstarget =_ blank>打开myexcel.xls< / a> 

或通过JS:

 函数openExcelFile(strFilePath){
if(window.ActiveXObject){
try {
var objExcel;
objExcel = new ActiveXObject(Excel.Application);
objExcel.Visible = true;
objExcel.Workbooks.Open(strLocation,false,[只读:true | false]);
}
catch(e){
alert(e.message);
}
}
其他{
alert(您的浏览器不支持此操作。);
}
}


How to use javascript or jQuery to open an excel html file in excel from the browser?

I've been trying to just use the window.open(href) to open an html excel file. It location on server is: /server/excelfiles/myexcel.xls, and I'm trying to open it in an excel app and not in an active x control in IE browser. Its this even possible to open up a file in the application instead of the browser?

解决方案

Two methods:

<a href="/server/excelfiles/myexcel.xls" target="_blank">open myexcel.xls</a> 

or via JS:

function openExcelFile(strFilePath) {
    if (window.ActiveXObject) {
        try {
            var objExcel;
            objExcel = new ActiveXObject("Excel.Application");
            objExcel.Visible = true;
            objExcel.Workbooks.Open(strLocation, false, [readonly: true|false]);
        }
        catch (e) {
            alert (e.message);
        }
    }
    else {
        alert ("Your browser does not support this.");
    }
}

这篇关于如何在Excel应用程序中使用javascript打开excel html文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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