Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Angularjs导出到Excel-不';不能在IE中工作,不能在ff和chrome中使用excel_Javascript_Html_Angularjs_Excel_Jsp - Fatal编程技术网

Javascript Angularjs导出到Excel-不';不能在IE中工作,不能在ff和chrome中使用excel

Javascript Angularjs导出到Excel-不';不能在IE中工作,不能在ff和chrome中使用excel,javascript,html,angularjs,excel,jsp,Javascript,Html,Angularjs,Excel,Jsp,我一直在尝试使用AngularJs将一个表从jsp页面导出到Excel Angularjs不会在IE中工作吗?同时,获取此错误SCRIPT5009:“节点”未定义 在Chrome和Firefox中,excel只有在保存时才会打开,而不是使用openwith选项打开。保存的Excel不正确。几个星期都在努力解决这个问题 甚至尝试过使用Jquery,但没有成功。 请给我一个解决方案。非常感谢 我的jsp: <html> <head> <script src="/Puls

我一直在尝试使用AngularJs将一个表从jsp页面导出到Excel

Angularjs不会在IE中工作吗?同时,获取此错误
SCRIPT5009:“节点”未定义

在Chrome和Firefox中,excel只有在保存时才会打开,而不是使用
openwith
选项打开。保存的Excel不正确。几个星期都在努力解决这个问题

甚至尝试过使用Jquery,但没有成功。 请给我一个解决方案。非常感谢

我的jsp:

<html>
<head>
<script src="/Pulse/static/scripts/jquery-1.11.2.min.js"></script><script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.js"></script>
<script src="https://rawgithub.com/eligrey/FileSaver.js/master/FileSaver.js" type="text/javascript"></script>
</head>
<body>
<div id="myCtrl" ng-app="myApp" ng-controller="myCtrl">
<table>
    <tr><td>
    <p ng-click="exportData()" id="myImg">Click here</p>
    </td></tr>
</table>
    <div id="exportable">
    <table width="100%" id="myTable">
        <thead>
            <tr>
                <th>Num</th>
                <th>Sq</th>
            </tr>
        </thead>
        <tbody>
         <tr>
                <td>2</td>
                <td>4</td>
            </tr>
        </tbody>
    </table>
    </div>
</div>  
</body>
</html>

单击此处

号码 平方英尺 2. 4.
我的天使:

<script>
var myApp = angular.module('myApp', []);
myApp.controller('myCtrl',function($scope, $http) {
    $scope.exportData = function() {
        var blob = new Blob(
                [ document.getElementById('myTable').innerHTML ],
                {
                    type : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
                });
        window.saveAs(blob, "MyRep.xls");
    }
});
</script>

var myApp=angular.module('myApp',[]);
控制器('myCtrl',函数($scope,$http){
$scope.exportData=函数(){
var blob=新blob(
[document.getElementById('myTable').innerHTML],
{
类型:“application/vnd.openxmlformats of cedocument.spreadsheetml.sheet;charset=utf-8”
});
saveAs(blob,“MyRep.xls”);
}
});
在firefox中单击
openwith
excel时,我发现:

打开保存的excel时:

有人能指出我做错了什么吗

您可以这样做:

var myApp = angular.module('myApp', ['ui.bootstrap', 'ngAnimate', 'ngTouch', 'mgcrea.ngStrap']);myApp.controller('myCtrl',function($scope, $http,$timeout) {

$scope.exportData = function() {
    $timeout(function () {
        var blob = new Blob([ document.getElementById('myTable').innerHTML ],
        {
            type : "application/vnd.ms-excel"
        });
    saveAs(blob, "MyRep.xls");}, 2000);
}
}))

我想这在firefox中运行得很好

我在我的页面中使用了其他脚本

<link href="~/Content/Controls/AngularStrap/libs.min.css" rel="stylesheet" /><script src="~/Content/Controls/AngularStrap/angular-strap.min.js"></script><script src="~/Content/Controls/AngularStrap/angular-strap.tpl.min.js"></script><script src="~/Content/Controls/FileSaver/FileSaver.js"></script>

@Piyush Khatri您能告诉我,甚至可以使用angularjs导出到IE中的excel吗?