我想将数据导出到excel或pdf,但是在IE中无法正常工作。我试图将其导出到Chrome中,并且可以正常工作。
但是,大多数将使用我的项目的人都在使用Internet Explorer。谁能看看我的代码,甚至可以建议我该怎么做?

这是我的Angular函数:

          scope.exportData = function () {
            var date = new Date();
            var d = date.getFullYear() + '-' + date.getMonth() + 1 + '-' + date.getDate();
            var blob = new Blob([document.getElementById('exportable').innerHTML], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"

            });
            saveAs(blob, "Report_" + d + ".xls");
        };

        scope.exportDataItems = function () {
            var date = new Date();
            var d = date.getFullYear() + '-' + date.getMonth() + 1 + '-' + date.getDate();
            var blob = new Blob([document.getElementById('exportablePRItems').innerHTML], {
                type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"

            });
            saveAs(blob, "Items_"+ d +".xls");
        };


    }]);

我实际上正在使用Blob.js

最佳答案

也许这会有所帮助。 :)

  scope.exportDataNew = function () {
                var d = new Date();
                var mont = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
                if (typeof scope.filter_fromDate == 'undefined') {
                    scope.filter_fromDate = mont[d.getMonth()] + ' ' + d.getDate().toString() + ", " + d.getFullYear().toString();

                }
                if (typeof scope.filter_toDate == 'undefined') {
                    scope.filter_toDate = mont[d.getMonth()] + ' ' + d.getDate().toString() + ", " + d.getFullYear().toString();
                }
                if (typeof scope.EntityID == 'undefined') {
                    scope.EntityID = "";
                }
                if (typeof scope.DepartmentID == 'undefined') {
                    scope.DepartmentID = "";
                }
                location.href = 'ExportExcel?from=' + scope.filter_fromDate + '&to=' + scope.filter_toDate + '&EntityID=' + scope.EntityID + '&DepartmentID=' + scope.DepartmentID;
            };
            scope.exportData = function () {
                var date = new Date();
                var d = date.getFullYear() + '-' + date.getMonth() + 1 + '-' + date.getDate();
                var blob = new Blob([document.getElementById('exportable').innerHTML], {
                    type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"

                });
                saveAs(blob, "Report_" + d + ".xls");
            };

10-08 11:35