本文介绍了在Internet Explorer中将HTML表格导出为使用Javascript中的excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从客户端的按钮点击事件中获得以下代码。它在Chrome中打开了excel。但是,在IE中,它只是追加到URL中,并且它不能按需运行。

I have the following code from button click event in client side. It is opening the excel in Chrome. However, in IE, it is just appending to the URL and it is not working as desired.

function generateexcel() {

    var table = document.getElementById("tsttable");

    var c = table.innerHTML;

    var html = c.trim()

    //add more symbols if needed...
    while (html.indexOf('á') != -1) html = html.replace('á', 'á');
    while (html.indexOf('é') != -1) html = html.replace('é', 'é');
    while (html.indexOf('í') != -1) html = html.replace('í', 'í');
    while (html.indexOf('ó') != -1) html = html.replace('ó', 'ó');
    while (html.indexOf('ú') != -1) html = html.replace('ú', 'ú');
    while (html.indexOf('º') != -1) html = html.replace('º', 'º');

    window.open('data:application/vnd.ms-excel,' + escape(html));
}


推荐答案

您可以将表格更改为xml或csv在IE中。所以你的用户可以用excel打开它。祝你好运。

You can change your table to xml or csv in IE. So your user can open it with excel. Good Luck.

这篇关于在Internet Explorer中将HTML表格导出为使用Javascript中的excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 22:01